Simple single-color 8x8x8 LED Cube with AVRs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

layerEditFrame.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import javax.swing.event.*;
  5. /**
  6. *
  7. * Beschreibung
  8. *
  9. * @version 1.0 vom 11/16/2011
  10. * @author
  11. */
  12. public class layerEditFrame extends JFrame {
  13. // Anfang Attribute
  14. private JPanel panelLED1 = new JPanel(null, true);
  15. public static ImageIcon on = new ImageIcon("LEDon.png");
  16. public static ImageIcon off = new ImageIcon("LEDoff.png");
  17. JButton[][] ledPanels = new JButton[8][8];
  18. // Ende Attribute
  19. public layerEditFrame() {
  20. // Frame-Initialisierung
  21. super("Layer Edit");
  22. setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  23. int frameWidth = 180;
  24. int frameHeight = 230;
  25. setSize(frameWidth, frameHeight);
  26. Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
  27. int x = (d.width - getSize().width) / 2;
  28. int y = (d.height - getSize().height) / 2;
  29. setLocation(x, y);
  30. setResizable(false);
  31. Container cp = getContentPane();
  32. cp.setLayout(null);
  33. for(int i = 0; i < 8; i++){
  34. for(int j = 0; j < 8; j++){
  35. System.out.println(x);
  36. System.out.println(y);
  37. ledPanels[i][j] = new JButton(on);
  38. ledPanels[i][j].setBounds((i*20)+5, (j*20)+5, 15, 15);
  39. ledPanels[i][j].setVisible(true);
  40. cp.add(ledPanels[i][j]);
  41. }
  42. }
  43. JButton saveBtn = new JButton("Save");
  44. JButton cancelBtn = new JButton("Cancel");
  45. saveBtn.setBounds(5, 170, 70, 25);
  46. saveBtn.setFont(new Font("Dialog", Font.PLAIN, 13));
  47. cp.add(saveBtn);
  48. cancelBtn.setBounds(80, 170, 80, 25);
  49. cancelBtn.setFont(new Font("Dialog", Font.PLAIN, 13));
  50. cp.add(cancelBtn);
  51. setVisible(true);
  52. saveBtn.addActionListener(new ActionListener() {
  53. public void actionPerformed(ActionEvent evt) {
  54. save();
  55. }
  56. });
  57. cancelBtn.addActionListener(new ActionListener() {
  58. public void actionPerformed(ActionEvent evt) {
  59. cancel();
  60. }
  61. });
  62. addWindowListener(new WindowAdapter() {
  63. public void windowClosing(WindowEvent evt) {
  64. saveExitDialog();
  65. dispose();
  66. }
  67. });
  68. }
  69. // Anfang Komponenten
  70. // Ende Komponenten
  71. /*public void btnClicked(){
  72. if (getIcon() == on){
  73. setIcon(off);
  74. } else {
  75. setIcon(on);
  76. }
  77. } */
  78. public void cancel(){
  79. dispose();
  80. }
  81. public void save(){
  82. }
  83. private int saveExitDialog() {
  84. String[] Optionen = {"Yes", "No"};
  85. int Auswahl = JOptionPane.showOptionDialog(this, "Do you want to save your changes?", "Save?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, Optionen, Optionen[0]);
  86. if (Auswahl == JOptionPane.YES_OPTION) {
  87. save();
  88. return 1;
  89. } else {
  90. return 0;
  91. }
  92. }
  93. }