ShowedInformationPopUp.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package ui.view;
  2. import java.awt.BorderLayout;
  3. import javax.swing.JDialog;
  4. import javax.swing.JPanel;
  5. import javax.swing.border.EmptyBorder;
  6. import classes.IdCounter;
  7. import javax.swing.JCheckBox;
  8. import javax.swing.JButton;
  9. import java.awt.event.ActionListener;
  10. import java.awt.event.ActionEvent;
  11. /**
  12. * This Class represents a Popup to edit the shown Information.
  13. *
  14. * @author Gruppe14
  15. */
  16. public class ShowedInformationPopUp extends JDialog {
  17. private static final long serialVersionUID = 1L;
  18. private final JPanel contentPanel = new JPanel();
  19. private final JButton btnOk = new JButton("OK");
  20. private MyCanvas canvas;
  21. private JCheckBox objectEnergyCheckbox;
  22. private JCheckBox connectionCheckbox;
  23. /**
  24. * Constructor.
  25. *
  26. * @param canvas
  27. * the Canvas
  28. */
  29. public ShowedInformationPopUp(MyCanvas canvas) {
  30. super((java.awt.Frame) null, true);
  31. setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
  32. this.setTitle(Languages.getLanguage()[31]);
  33. setBounds(100, 100, 400, 169);
  34. getContentPane().setLayout(new BorderLayout());
  35. contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
  36. getContentPane().add(contentPanel, BorderLayout.CENTER);
  37. contentPanel.setLayout(null);
  38. this.canvas = canvas;
  39. objectEnergyCheckbox = new JCheckBox(Languages.getLanguage()[32]);
  40. objectEnergyCheckbox.setBounds(19, 19, 300, 23);
  41. contentPanel.add(objectEnergyCheckbox);
  42. connectionCheckbox = new JCheckBox(Languages.getLanguage()[33]);
  43. connectionCheckbox.setBounds(19, 57, 300, 23);
  44. contentPanel.add(connectionCheckbox);
  45. objectEnergyCheckbox.setSelected(canvas.getShowedInformation()[1]);
  46. connectionCheckbox.setSelected(canvas.getShowedInformation()[0]);
  47. btnOk.addActionListener(new ActionListener() {
  48. public void actionPerformed(ActionEvent arg0) {
  49. setInformation(connectionCheckbox.isSelected(), objectEnergyCheckbox.isSelected());
  50. dispose();
  51. }
  52. });
  53. btnOk.setBounds(169, 98, 82, 23);
  54. contentPanel.add(btnOk);
  55. JButton btnCancel = new JButton(Languages.getLanguage()[34]);
  56. btnCancel.setActionCommand(Languages.getLanguage()[34]);
  57. btnCancel.addActionListener(new ActionListener() {
  58. public void actionPerformed(ActionEvent arg0) {
  59. dispose();
  60. }
  61. });
  62. btnCancel.setBounds(70, 98, 89, 23);
  63. contentPanel.add(btnCancel);
  64. }
  65. /**
  66. * Set the Information true or false.
  67. *
  68. * @param connection
  69. * conecction Information
  70. * @param object
  71. * Object Information
  72. */
  73. private void setInformation(boolean connection, boolean object) {
  74. canvas.setShowedInformation(connection, object);
  75. canvas.repaint();
  76. }
  77. }