1
2
3
4
5
6
7
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
35 votView = new JVot();
36 getContentPane().add(votView.newVotScrollPanel(), BorderLayout.CENTER);
37 votController = new JVotController(votView);
38
39
40
41
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
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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148