1 19 20 package org.lucane.applications.notes.gui.main; 21 22 import org.lucane.applications.notes.*; 23 24 import java.awt.*; 25 import java.awt.event.*; 26 import javax.swing.*; 27 28 class ButtonPanel extends JPanel 29 { 30 private JButton newNote; 31 private JButton editNote; 32 private JButton removeNote; 33 private JButton addComment; 34 private JButton close; 35 36 public ButtonPanel(NotesPlugin parent, ActionListener listener) 37 { 38 super(); 40 this.setLayout(new BorderLayout()); 41 42 this.newNote = new JButton(parent.tr("main.newNote")); 43 this.editNote = new JButton(parent.tr("main.editNote")); 44 this.removeNote = new JButton(parent.tr("main.removeNote")); 45 this.addComment = new JButton(parent.tr("main.addComment")); 46 this.close = new JButton(parent.tr("main.close")); 47 48 newNote.setName("newNote"); 49 newNote.addActionListener(listener); 50 editNote.setName("editNote"); 51 editNote.addActionListener(listener); 52 removeNote.setName("removeNote"); 53 removeNote.addActionListener(listener); 54 addComment.setName("addComment"); 55 addComment.addActionListener(listener); 56 close.setName("close"); 57 close.addActionListener(listener); 58 59 JPanel grid = new JPanel(new GridLayout(5, 1, 0, 2)); 60 grid.add(newNote); 61 grid.add(editNote); 62 grid.add(removeNote); 63 grid.add(new JLabel("")); 64 grid.add(addComment); 65 66 allowComments(false); 67 allowEdition(false); 68 69 this.add(grid, BorderLayout.NORTH); 70 this.add(close, BorderLayout.SOUTH); 71 } 72 73 public void allowComments(boolean state) 74 { 75 addComment.setEnabled(state); 76 } 77 78 public void allowEdition(boolean state) 79 { 80 editNote.setEnabled(state); 81 removeNote.setEnabled(state); 82 } 83 } 84 | Popular Tags |