Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.dua3.utility.swing;
import com.dua3.utility.options.Arguments;
import com.dua3.utility.options.ArgumentsParser;
import com.dua3.utility.options.Option;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Window;
import java.util.Collection;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Supplier;
/**
* Represents a dialog that allows users to input arguments for a command-line program.
* The dialog displays a list of options, each with an input field for the user to provide the corresponding value.
* The dialog provides an "OK" button to accept the input and a "Cancel" button to close the dialog without saving the input.
*
* Usage:
* {@code
* ArgumentsParser parser = new ArgumentsParser();
* // Add options to the parser
* ArgumentsDialog.showDialog(window, parser);
* Optional arguments = ArgumentsDialog.showDialog(window, parser);
* }
*/
public class ArgumentsDialog extends JDialog {
private static final Logger LOG = LogManager.getLogger(ArgumentsDialog.class);
private final ArgumentsPanel panel;
/**
* A custom extension of JPanel that displays input fields for options defined by an ArgumentsParser.
*
* The ArgumentsPanel class provides a way to create a panel with input fields for each option defined by an ArgumentsParser.
* It also handles the retrieval and storage of user inputs for each option.
*
* The constructor takes an ArgumentsParser, which defines the options to be displayed, and two Runnables,
* onOk and onCancel, which are executed when the corresponding buttons are clicked.
*
* The panel is constructed with a GridBagLayout and adds JLabels and JTextFields for each option defined
* by the parser. The user inputs are stored in a {@code Map