View Javadoc

1   /*
2    * $Id: JVotBox.java,v 1.1 2004/04/15 16:34:53 mch Exp $
3    *
4    * Copyright 2003 AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid Software License,
7    * a copy of which has been included with this distribution in the LICENSE.txt file.
8    *
9    */
10  
11  package org.astrogrid.ui.votable;
12  
13  import java.awt.*;
14  import java.awt.event.*;
15  import javax.swing.*;
16  import org.astrogrid.ui.EscEnterListener;
17  import org.astrogrid.ui.IconFactory;
18  
19  
20  public class JVotBox extends JFrame
21  {
22     JVot votView = null;
23     JVotController votController = null;
24     
25     
26     /***
27      * Initializes the dialog.
28      */
29     public JVotBox(Frame owner)
30     {
31        super("VOTable Viewer");
32        getContentPane().setLayout(new BorderLayout());
33  
34        // add vot table panel
35        votView = new JVot();
36        getContentPane().add(votView.newVotScrollPanel(), BorderLayout.CENTER);
37        votController = new JVotController(votView);
38  
39        
40        
41        // Add window listener.
42        this.addWindowListener
43        (
44           new WindowAdapter()
45           {
46              /***
47               * Called when window close button was pressed.
48               */
49              public void windowClosing(WindowEvent e)
50              {
51                 setVisible(false);
52              }
53           }
54        );
55  
56        // add toolbar along the top
57        JToolBar toolbar = new JToolBar();
58        getContentPane().add(toolbar, BorderLayout.NORTH);
59  
60        JButton saveButton = new JButton(IconFactory.getIcon("SaveAs"));
61        if (saveButton.getIcon() == null)
62        {
63           saveButton.setText("Save As");
64        }
65        saveButton.setToolTipText("Save VOTable to file");
66        saveButton.setActionCommand(JVotController.SAVEAS_CMD);
67        saveButton.addActionListener(votController);
68        toolbar.add(saveButton);
69  
70        JButton loadButton = new JButton(IconFactory.getIcon("Open"));
71        if (loadButton.getIcon() == null)
72        {
73           loadButton.setText("Open");
74        }
75        loadButton.setToolTipText("Load new VOTable from file");
76        loadButton.setActionCommand(JVotController.LOAD_CMD);
77        loadButton.addActionListener(votController);
78        toolbar.add(loadButton);
79  
80        new EscEnterListener(this, null, null);
81  
82        validate();
83     }
84  
85     /***
86      * Expose the JVot component
87      */
88     public JVot getVotTable()
89     {
90        return votView;
91     }
92  
93     /***
94      * Expose the JVotController component
95      */
96     public JVotController getVotController()
97     {
98        return votController;
99     }
100    /***
101     * Shows the frame.
102     */
103    public void show()
104    {
105       // You can also use: Dimension size = new Dimension(300,200);
106       Dimension size = getPreferredSize();
107       Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
108       setBounds
109       (
110          (screenSize.width - size.width) / 2,
111          (screenSize.height - size.height) / 2,
112          size.width,
113          size.height
114       );
115 
116       super.show();
117    }
118 
119    /***
120     * Test harness and standalone VOTable viewer
121     */
122    public static void main(String [] args)
123    {
124 
125       JVotBox vb = new JVotBox(null);
126 
127       vb.show();
128    }
129     /***/
130 
131 
132 }
133 /*
134 $Log: JVotBox.java,v $
135 Revision 1.1  2004/04/15 16:34:53  mch
136 Tidied up, introduced stuff from datacenter ui
137 
138 Revision 1.1  2004/03/03 17:40:58  mch
139 Moved ui package
140 
141 Revision 1.1  2004/02/17 16:04:06  mch
142 New Desktop GUI
143 
144 Revision 1.1  2004/02/15 23:25:30  mch
145 Datacenter and MySpace desktop client GUIs
146 
147  */
148