gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.main / src / main / java / org / gvsig / tools / main / Main.java @ 447
History | View | Annotate | Download (2.92 KB)
1 |
package org.gvsig.tools.main; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.event.ActionEvent; |
6 |
import java.awt.event.ActionListener; |
7 |
|
8 |
import javax.swing.JButton; |
9 |
import javax.swing.JFrame; |
10 |
import javax.swing.JMenu; |
11 |
import javax.swing.JMenuBar; |
12 |
import javax.swing.JMenuItem; |
13 |
import javax.swing.JTabbedPane; |
14 |
import javax.swing.JToolBar; |
15 |
import javax.swing.WindowConstants; |
16 |
|
17 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
18 |
import org.gvsig.tools.main.dynobject.DynObjectComponentAction; |
19 |
import org.gvsig.tools.main.dynobject.DynObjectSetComponentAction; |
20 |
import org.gvsig.tools.main.taskstatus.JTaskStatusAction; |
21 |
import org.gvsig.tools.main.usability.UsabilityAction; |
22 |
|
23 |
/**
|
24 |
* @author 2010- C?sar Ordi?ana - gvSIG team
|
25 |
*/
|
26 |
public class Main { |
27 |
|
28 |
private JTabbedPane tabbedPane; |
29 |
private JMenuBar menuBar; |
30 |
private JToolBar toolBar; |
31 |
|
32 |
public static void main(String args[]) { |
33 |
new DefaultLibrariesInitializer().fullInitialize();
|
34 |
Main main = new Main();
|
35 |
main.show(); |
36 |
} |
37 |
|
38 |
public void show() { |
39 |
|
40 |
final JFrame frame = new JFrame("Tools swing components test app"); |
41 |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
42 |
|
43 |
// Add a tabbed pane as a content pane
|
44 |
tabbedPane = new JTabbedPane(); |
45 |
tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
|
46 |
frame.getContentPane().add(tabbedPane); |
47 |
|
48 |
// Create application actions
|
49 |
MainAction[] actions = createActions();
|
50 |
|
51 |
// Create the menu bar.
|
52 |
menuBar = new JMenuBar(); |
53 |
|
54 |
// Build the menu.
|
55 |
JMenu menuFile = new JMenu("File"); |
56 |
JMenuItem menuItemExit = new JMenuItem("Exit"); |
57 |
menuItemExit.addActionListener(new ActionListener() { |
58 |
|
59 |
public void actionPerformed(ActionEvent e) { |
60 |
frame.dispose(); |
61 |
System.exit(0); |
62 |
} |
63 |
}); |
64 |
menuFile.add(menuItemExit); |
65 |
menuBar.add(menuFile); |
66 |
|
67 |
// Add all actions to the menu bar
|
68 |
JMenu menuDemo = new JMenu("Tools components"); |
69 |
for (int i = 0; i < actions.length; i++) { |
70 |
menuDemo.add(new JMenuItem(actions[i])); |
71 |
} |
72 |
menuBar.add(menuDemo); |
73 |
|
74 |
// Build the toolbar
|
75 |
toolBar = new JToolBar("Main toolbar"); |
76 |
|
77 |
// Add all actions to the toolbar
|
78 |
for (int i = 0; i < actions.length; i++) { |
79 |
toolBar.add(new JButton(actions[i])); |
80 |
} |
81 |
|
82 |
frame.setPreferredSize(new Dimension(800, 600)); |
83 |
|
84 |
frame.setJMenuBar(menuBar); |
85 |
frame.add(toolBar, BorderLayout.PAGE_START);
|
86 |
|
87 |
// Display the window.
|
88 |
frame.pack(); |
89 |
frame.setVisible(true);
|
90 |
} |
91 |
|
92 |
private MainAction[] createActions() { |
93 |
return new MainAction[] { |
94 |
new DynObjectComponentAction(tabbedPane),
|
95 |
new DynObjectSetComponentAction(tabbedPane),
|
96 |
new UsabilityAction(tabbedPane),
|
97 |
new JTaskStatusAction(tabbedPane)
|
98 |
}; |
99 |
} |
100 |
|
101 |
} |