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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. JButton[][] ledPanels = new JButton[8][8];
  16. static ImageIcon on = new ImageIcon("LEDon.png");
  17. static ImageIcon off = new ImageIcon("LEDff.png");
  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. ledPanels[i][j] = new JButton(on);
  36. ledPanels[i][j].setBounds((i*20)+5, (j*20)+5, 15, 15);
  37. ledPanels[i][j].setVisible(true);
  38. cp.add(ledPanels[i][j]);
  39. }
  40. }
  41. JButton saveBtn = new JButton("Save");
  42. JButton cancelBtn = new JButton("Cancel");
  43. saveBtn.setBounds(5, 170, 70, 25);
  44. saveBtn.setFont(new Font("Dialog", Font.PLAIN, 13));
  45. cp.add(saveBtn);
  46. cancelBtn.setBounds(80, 170, 80, 25);
  47. cancelBtn.setFont(new Font("Dialog", Font.PLAIN, 13));
  48. cp.add(cancelBtn);
  49. setVisible(true);
  50. saveBtn.addActionListener(new ActionListener() {
  51. public void actionPerformed(ActionEvent evt) {
  52. save();
  53. }
  54. });
  55. cancelBtn.addActionListener(new ActionListener() {
  56. public void actionPerformed(ActionEvent evt) {
  57. cancel();
  58. }
  59. });
  60. addWindowListener(new WindowAdapter() {
  61. public void windowClosing(WindowEvent evt) {
  62. saveExitDialog();
  63. dispose();
  64. }
  65. });
  66. }
  67. // Anfang Komponenten
  68. // Ende Komponenten
  69. /*public void btnClicked(){
  70. if (getIcon() == on){
  71. setIcon(off);
  72. } else {
  73. setIcon(on);
  74. }
  75. } */
  76. public void cancel(){
  77. dispose();
  78. }
  79. public void save(){
  80. }
  81. private int saveExitDialog() {
  82. String[] Optionen = {"Yes", "No"};
  83. int Auswahl = JOptionPane.showOptionDialog(this, "Do you want to save your changes?", "Save?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, Optionen, Optionen[0]);
  84. if (Auswahl == JOptionPane.YES_OPTION) {
  85. save();
  86. return 1;
  87. } else {
  88. return 0;
  89. }
  90. }
  91. }