12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- package ui.view;
- import java.awt.BorderLayout;
- import java.awt.FlowLayout;
- import javax.swing.JButton;
- import javax.swing.JDialog;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JLabel;
- import javax.swing.JTextField;
- import javax.swing.JComboBox;
- import javax.swing.DefaultComboBoxModel;
- public class AddElementPopUp extends JDialog {
- private final JPanel contentPanel = new JPanel();
- private JTextField textField;
- private JTextField textField_1;
- private JTextField textField_2;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- try {
- AddElementPopUp dialog = new AddElementPopUp();
- dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- dialog.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * Create the dialog.
- */
- public AddElementPopUp() {
- setBounds(100, 100, 300, 190);
- getContentPane().setLayout(new BorderLayout());
- contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
- getContentPane().add(contentPanel, BorderLayout.CENTER);
- contentPanel.setLayout(null);
- this.setTitle("Add default Element to Object");
-
- JLabel lblElementName = new JLabel("Element Name:");
- lblElementName.setBounds(10, 11, 79, 14);
- contentPanel.add(lblElementName);
-
- JLabel lblProvidedEnergy = new JLabel("Provided Energy:");
- lblProvidedEnergy.setBounds(10, 49, 90, 14);
- contentPanel.add(lblProvidedEnergy);
-
- JLabel lblAmount = new JLabel("Amount:");
- lblAmount.setBounds(10, 84, 46, 14);
- contentPanel.add(lblAmount);
-
- textField = new JTextField();
- textField.setBounds(140, 8, 110, 20);
- contentPanel.add(textField);
- textField.setColumns(10);
-
- JComboBox comboBox = new JComboBox();
- comboBox.setModel(new DefaultComboBoxModel(new String[] {"+", "-"}));
- comboBox.setBounds(100, 46, 33, 20);
- contentPanel.add(comboBox);
-
- textField_1 = new JTextField();
- textField_1.setBounds(140, 46, 110, 20);
- contentPanel.add(textField_1);
- textField_1.setColumns(10);
-
- textField_2 = new JTextField();
- textField_2.setBounds(140, 81, 110, 20);
- contentPanel.add(textField_2);
- textField_2.setColumns(10);
- {
- JPanel buttonPane = new JPanel();
- buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
- getContentPane().add(buttonPane, BorderLayout.SOUTH);
- {
- JButton okButton = new JButton("OK");
- okButton.setActionCommand("OK");
- buttonPane.add(okButton);
- getRootPane().setDefaultButton(okButton);
- }
- {
- JButton cancelButton = new JButton("Cancel");
- cancelButton.setActionCommand("Cancel");
- buttonPane.add(cancelButton);
- }
- }
- }
- }
|