KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > BasicConsole


1 /*====================================================================
2
3 Objectweb Browser Framework
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle, Jerome Moroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 import java.awt.BorderLayout JavaDoc;
28 import java.util.Vector JavaDoc;
29
30 import javax.swing.JFrame JavaDoc;
31 import javax.swing.JSplitPane JavaDoc;
32
33 import org.objectweb.util.browser.core.api.ContextContainer;
34 import org.objectweb.util.browser.core.api.StatusBar;
35 import org.objectweb.util.browser.core.api.ViewPanel;
36 import org.objectweb.util.browser.core.common.DefaultStatusBar;
37 import org.objectweb.util.browser.core.common.DefaultTreePanel;
38 import org.objectweb.util.browser.core.common.DefaultViewPanel;
39 import org.objectweb.util.browser.core.common.DynamicTree;
40 import org.objectweb.util.browser.core.naming.DefaultContextContainer;
41
42 /**
43  * This class builds a example console built on top of the Browser Framework.
44  * This console allows us to manage various Java Object such as <code>java.util.List</code>.
45  *
46  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>,
47  * <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>
48  *
49  * @version 0.1
50  */

51 public class BasicConsole {
52
53     public BasicConsole(String JavaDoc configFile){
54         // Creates the main frame
55
JFrame JavaDoc frame = new JFrame JavaDoc("Browser GUI");
56         
57         // Creates the view panel
58
ViewPanel viewPanel = new DefaultViewPanel();
59         
60         // Creates the status bar
61
StatusBar statusBar = new DefaultStatusBar();
62         
63         // Creates the tree
64
DynamicTree tree = new DynamicTree();
65            
66         // Populates the tree
67
tree.addEntry("Java Properties", System.getProperties());
68         ContextContainer contextContainer = new DefaultContextContainer();
69         contextContainer.addEntry("Object 1", new Object JavaDoc());
70         contextContainer.addEntry("Object 2", new Object JavaDoc());
71         tree.addEntry("Context", contextContainer);
72         tree.addEntry("Vector", new Vector JavaDoc());
73         
74         // Configures the tree
75
tree.setNewBrowserProperty(new String JavaDoc[]{configFile});
76         tree.setTargetPanel(viewPanel);
77         tree.setStatusBar(statusBar);
78         
79         // Configures the main frame
80
frame.getContentPane().setLayout(new BorderLayout JavaDoc());
81         frame.getContentPane().add(
82             new JSplitPane JavaDoc(
83                 JSplitPane.HORIZONTAL_SPLIT,
84                 true,
85                 new DefaultTreePanel((DynamicTree)tree),
86                 ((DefaultViewPanel)viewPanel)),
87             BorderLayout.CENTER);
88         frame.getContentPane().add((DefaultStatusBar)statusBar, BorderLayout.SOUTH);
89         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
90         frame.pack();
91         frame.setVisible(true);
92     }
93
94     public static void main(String JavaDoc[] args){
95         if(args.length != 0)
96             new BasicConsole(args[0]);
97     }
98
99 }
100
Popular Tags