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

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