gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.main / src / main / java / org / gvsig / tools / main / Main.java @ 1124
History | View | Annotate | Download (3.71 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.tools.main; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
import java.awt.Dimension; |
28 |
import java.awt.event.ActionEvent; |
29 |
import java.awt.event.ActionListener; |
30 |
|
31 |
import javax.swing.JButton; |
32 |
import javax.swing.JFrame; |
33 |
import javax.swing.JMenu; |
34 |
import javax.swing.JMenuBar; |
35 |
import javax.swing.JMenuItem; |
36 |
import javax.swing.JTabbedPane; |
37 |
import javax.swing.JToolBar; |
38 |
import javax.swing.WindowConstants; |
39 |
|
40 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
41 |
import org.gvsig.tools.main.taskstatus.JTaskStatusAction; |
42 |
import org.gvsig.tools.main.usability.UsabilityAction; |
43 |
import org.gvsig.tools.main.window.ModalAction; |
44 |
|
45 |
/**
|
46 |
* @author 2010- C?sar Ordi?ana - gvSIG team
|
47 |
*/
|
48 |
public class Main { |
49 |
|
50 |
private JTabbedPane tabbedPane; |
51 |
private JMenuBar menuBar; |
52 |
private JToolBar toolBar; |
53 |
|
54 |
public static void main(String args[]) { |
55 |
new DefaultLibrariesInitializer().fullInitialize();
|
56 |
Main main = new Main();
|
57 |
main.show(); |
58 |
} |
59 |
|
60 |
public void show() { |
61 |
|
62 |
final JFrame frame = new JFrame("Tools swing components test app"); |
63 |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
64 |
|
65 |
// Add a tabbed pane as a content pane
|
66 |
tabbedPane = new JTabbedPane(); |
67 |
tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
|
68 |
frame.getContentPane().add(tabbedPane); |
69 |
|
70 |
// Create application actions
|
71 |
MainAction[] actions = createActions();
|
72 |
|
73 |
// Create the menu bar.
|
74 |
menuBar = new JMenuBar(); |
75 |
|
76 |
// Build the menu.
|
77 |
JMenu menuFile = new JMenu("File"); |
78 |
JMenuItem menuItemExit = new JMenuItem("Exit"); |
79 |
menuItemExit.addActionListener(new ActionListener() { |
80 |
|
81 |
public void actionPerformed(ActionEvent e) { |
82 |
frame.dispose(); |
83 |
System.exit(0); |
84 |
} |
85 |
}); |
86 |
menuFile.add(menuItemExit); |
87 |
menuBar.add(menuFile); |
88 |
|
89 |
// Add all actions to the menu bar
|
90 |
JMenu menuDemo = new JMenu("Tools components"); |
91 |
for (int i = 0; i < actions.length; i++) { |
92 |
menuDemo.add(new JMenuItem(actions[i])); |
93 |
} |
94 |
menuBar.add(menuDemo); |
95 |
|
96 |
// Build the toolbar
|
97 |
toolBar = new JToolBar("Main toolbar"); |
98 |
|
99 |
// Add all actions to the toolbar
|
100 |
for (int i = 0; i < actions.length; i++) { |
101 |
toolBar.add(new JButton(actions[i])); |
102 |
} |
103 |
|
104 |
frame.setPreferredSize(new Dimension(800, 600)); |
105 |
|
106 |
frame.setJMenuBar(menuBar); |
107 |
frame.add(toolBar, BorderLayout.PAGE_START);
|
108 |
|
109 |
// Display the window.
|
110 |
frame.pack(); |
111 |
frame.setVisible(true);
|
112 |
} |
113 |
|
114 |
private MainAction[] createActions() { |
115 |
return new MainAction[] { |
116 |
new UsabilityAction(tabbedPane),
|
117 |
new JTaskStatusAction(tabbedPane),
|
118 |
new ModalAction(tabbedPane)
|
119 |
}; |
120 |
} |
121 |
|
122 |
} |