1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package ui.view;
- import java.awt.BorderLayout;
- import javax.swing.JDialog;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import classes.IdCounter;
- import javax.swing.JCheckBox;
- import javax.swing.JButton;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- /**
- * This Class represents a Popup to edit the shown Information.
- *
- * @author Gruppe14
- */
- public class ShowedInformationPopUp extends JDialog {
- private static final long serialVersionUID = 1L;
- private final JPanel contentPanel = new JPanel();
- private final JButton btnOk = new JButton("OK");
- private MyCanvas canvas;
- private JCheckBox objectEnergyCheckbox;
- private JCheckBox connectionCheckbox;
- /**
- * Constructor.
- *
- * @param canvas
- * the Canvas
- */
- public ShowedInformationPopUp(MyCanvas canvas) {
- super((java.awt.Frame) null, true);
- setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
- this.setTitle(Languages.getLanguage()[31]);
- setBounds(100, 100, 400, 169);
- getContentPane().setLayout(new BorderLayout());
- contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
- getContentPane().add(contentPanel, BorderLayout.CENTER);
- contentPanel.setLayout(null);
- this.canvas = canvas;
- objectEnergyCheckbox = new JCheckBox(Languages.getLanguage()[32]);
- objectEnergyCheckbox.setBounds(19, 19, 300, 23);
- contentPanel.add(objectEnergyCheckbox);
- connectionCheckbox = new JCheckBox(Languages.getLanguage()[33]);
- connectionCheckbox.setBounds(19, 57, 300, 23);
- contentPanel.add(connectionCheckbox);
- objectEnergyCheckbox.setSelected(canvas.getShowedInformation()[1]);
- connectionCheckbox.setSelected(canvas.getShowedInformation()[0]);
- btnOk.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- setInformation(connectionCheckbox.isSelected(), objectEnergyCheckbox.isSelected());
- dispose();
- }
- });
- btnOk.setBounds(169, 98, 82, 23);
- contentPanel.add(btnOk);
- JButton btnCancel = new JButton(Languages.getLanguage()[34]);
- btnCancel.setActionCommand(Languages.getLanguage()[34]);
- btnCancel.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- dispose();
- }
- });
- btnCancel.setBounds(70, 98, 89, 23);
- contentPanel.add(btnCancel);
- }
- /**
- * Set the Information true or false.
- *
- * @param connection
- * conecction Information
- * @param object
- * Object Information
- */
- private void setInformation(boolean connection, boolean object) {
- canvas.setShowedInformation(connection, object);
- canvas.repaint();
- }
- }
|