123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- package ui.view;
- import java.awt.BorderLayout;
- import javax.swing.JDialog;
- import javax.swing.JFrame;
- 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;
- private JCheckBox colorizedBorderCheckbox;
- private JPanel toUpdate;
- /**
- * Constructor.
- *
- * @param canvas
- * the Canvas
- */
- public ShowedInformationPopUp(MyCanvas canvas, JPanel update) {
- super((java.awt.Frame) null, true);
- setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
- this.setTitle(Languages.getLanguage()[31]);
- setBounds(100, 100, 400, 220);
- getContentPane().setLayout(new BorderLayout());
- contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
- getContentPane().add(contentPanel, BorderLayout.CENTER);
- contentPanel.setLayout(null);
- this.canvas = canvas;
- this.toUpdate = update;
- 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(),
- colorizedBorderCheckbox.isSelected());
- dispose();
- }
- });
- btnOk.setBounds(171, 147, 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(72, 147, 89, 23);
- contentPanel.add(btnCancel);
-
- colorizedBorderCheckbox = new JCheckBox("Show colorized Border for Objects");
- colorizedBorderCheckbox.setBounds(19, 96, 195, 23);
- contentPanel.add(colorizedBorderCheckbox);
- colorizedBorderCheckbox.setSelected(canvas.getShowedInformation()[3]);
- }
- /**
- * Set the Information true or false.
- *
- * @param connection
- * conection Information
- * @param object
- * Object Information
- */
- private void setInformation(boolean connection, boolean object, boolean borders) {
- canvas.setShowedInformation(connection, object, borders);
- canvas.repaint();
- toUpdate.updateUI();
- }
- }
|