Statistics
| Revision:

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 802 cordinyana
/**
2
 * gvSIG. Desktop Geographic Information System.
3 604 cordinyana
 *
4 802 cordinyana
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6 604 cordinyana
 * 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 802 cordinyana
 *
11 604 cordinyana
 * 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 802 cordinyana
 *
16 604 cordinyana
 * 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 802 cordinyana
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 604 cordinyana
 * MA  02110-1301, USA.
20 802 cordinyana
 *
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 604 cordinyana
 */
24 93 cordinyana
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 447 jjdelcerro
import org.gvsig.tools.main.taskstatus.JTaskStatusAction;
42 100 cordinyana
import org.gvsig.tools.main.usability.UsabilityAction;
43 556 fdiaz
import org.gvsig.tools.main.window.ModalAction;
44 93 cordinyana
45
/**
46
 * @author 2010- C?sar Ordi?ana - gvSIG team
47
 */
48
public class Main {
49
50 304 cordinyana
    private JTabbedPane tabbedPane;
51
    private JMenuBar menuBar;
52
    private JToolBar toolBar;
53
54 270 cmartin
    public static void main(String args[]) {
55
        new DefaultLibrariesInitializer().fullInitialize();
56
        Main main = new Main();
57
        main.show();
58
    }
59 93 cordinyana
60 270 cmartin
    public void show() {
61 93 cordinyana
62 270 cmartin
        final JFrame frame = new JFrame("Tools swing components test app");
63
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
64 93 cordinyana
65 270 cmartin
        // Add a tabbed pane as a content pane
66
        tabbedPane = new JTabbedPane();
67
        tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
68
        frame.getContentPane().add(tabbedPane);
69 93 cordinyana
70 270 cmartin
        // Create application actions
71
        MainAction[] actions = createActions();
72 93 cordinyana
73 270 cmartin
        // Create the menu bar.
74
        menuBar = new JMenuBar();
75 93 cordinyana
76 270 cmartin
        // Build the menu.
77
        JMenu menuFile = new JMenu("File");
78
        JMenuItem menuItemExit = new JMenuItem("Exit");
79
        menuItemExit.addActionListener(new ActionListener() {
80 93 cordinyana
81 270 cmartin
            public void actionPerformed(ActionEvent e) {
82
                frame.dispose();
83
                System.exit(0);
84
            }
85
        });
86
        menuFile.add(menuItemExit);
87
        menuBar.add(menuFile);
88 93 cordinyana
89 270 cmartin
        // 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 93 cordinyana
96 270 cmartin
        // Build the toolbar
97
        toolBar = new JToolBar("Main toolbar");
98 93 cordinyana
99 270 cmartin
        // Add all actions to the toolbar
100
        for (int i = 0; i < actions.length; i++) {
101
            toolBar.add(new JButton(actions[i]));
102
        }
103 93 cordinyana
104 270 cmartin
        frame.setPreferredSize(new Dimension(800, 600));
105 93 cordinyana
106 270 cmartin
        frame.setJMenuBar(menuBar);
107
        frame.add(toolBar, BorderLayout.PAGE_START);
108 93 cordinyana
109 270 cmartin
        // Display the window.
110
        frame.pack();
111
        frame.setVisible(true);
112
    }
113
114 304 cordinyana
    private MainAction[] createActions() {
115 447 jjdelcerro
        return new MainAction[] {
116
            new UsabilityAction(tabbedPane),
117 556 fdiaz
            new JTaskStatusAction(tabbedPane),
118
            new ModalAction(tabbedPane)
119 447 jjdelcerro
        };
120 304 cordinyana
    }
121
122 270 cmartin
}