KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > notes > gui > main > ButtonPanel


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2003 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

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         //panel config
39
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