author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 25859 | jdk/src/demo/share/jfc/TableExample/TableExample.java@3317bb8137f4 |
child 52252 | de9486d74a74 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
|
5 |
* modification, are permitted provided that the following conditions |
|
6 |
* are met: |
|
7 |
* |
|
8 |
* - Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* |
|
11 |
* - Redistributions in binary form must reproduce the above copyright |
|
12 |
* notice, this list of conditions and the following disclaimer in the |
|
13 |
* documentation and/or other materials provided with the distribution. |
|
14 |
* |
|
5506 | 15 |
* - Neither the name of Oracle nor the names of its |
2 | 16 |
* contributors may be used to endorse or promote products derived |
17 |
* from this software without specific prior written permission. |
|
18 |
* |
|
19 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
|
20 |
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
|
21 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
22 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
23 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
24 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
25 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
26 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
27 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
28 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
29 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
30 |
*/ |
|
31 |
||
10292
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8979
diff
changeset
|
32 |
/* |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8979
diff
changeset
|
33 |
* This source code is provided to illustrate the usage of a given feature |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8979
diff
changeset
|
34 |
* or technique and has been deliberately simplified. Additional steps |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8979
diff
changeset
|
35 |
* required for a production-quality application, such as security checks, |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8979
diff
changeset
|
36 |
* input validation and proper error handling, might not be present in |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8979
diff
changeset
|
37 |
* this sample code. |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8979
diff
changeset
|
38 |
*/ |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8979
diff
changeset
|
39 |
|
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8979
diff
changeset
|
40 |
|
2 | 41 |
|
42 |
/** |
|
43 |
* A a UI around the JDBCAdaptor, allowing database data to be interactively |
|
44 |
* fetched, sorted and displayed using Swing. |
|
45 |
* |
|
46 |
* NOTE: This example uses a modal dialog via the static convenience methods in |
|
47 |
* the JOptionPane. Use of modal dialogs requires JDK 1.1.4 or greater. |
|
48 |
* |
|
49 |
* @author Philip Milne |
|
50 |
*/ |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
51 |
import java.awt.Color; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
52 |
import java.awt.Component; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
53 |
import java.awt.Container; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
54 |
import java.awt.Dimension; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
55 |
import java.awt.GridLayout; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
56 |
import java.awt.LayoutManager; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
57 |
import java.awt.Rectangle; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
58 |
import java.awt.event.ActionEvent; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
59 |
import java.awt.event.ActionListener; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
60 |
import java.awt.event.WindowAdapter; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
61 |
import java.awt.event.WindowEvent; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
62 |
import java.util.logging.Level; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
63 |
import java.util.logging.Logger; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
64 |
import javax.swing.BoxLayout; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
65 |
import javax.swing.JButton; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
66 |
import javax.swing.JComponent; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
67 |
import javax.swing.JFrame; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
68 |
import javax.swing.JLabel; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
69 |
import javax.swing.JOptionPane; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
70 |
import javax.swing.JPanel; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
71 |
import javax.swing.JScrollPane; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
72 |
import javax.swing.JTable; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
73 |
import javax.swing.JTextArea; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
74 |
import javax.swing.JTextField; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
75 |
import javax.swing.UIManager; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
76 |
import javax.swing.UIManager.LookAndFeelInfo; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
77 |
import javax.swing.border.BevelBorder; |
2 | 78 |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
79 |
|
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
80 |
public final class TableExample implements LayoutManager { |
2 | 81 |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
82 |
static String[] ConnectOptionNames = { "Connect" }; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
83 |
static String ConnectTitle = "Connection Information"; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
84 |
Dimension origin = new Dimension(0, 0); |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
85 |
JButton fetchButton; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
86 |
JButton showConnectionInfoButton; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
87 |
JPanel connectionPanel; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
88 |
JFrame frame; // The query/results window. |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
89 |
JLabel userNameLabel; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
90 |
JTextField userNameField; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
91 |
JLabel passwordLabel; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
92 |
JTextField passwordField; |
2 | 93 |
// JLabel queryLabel; |
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
94 |
JTextArea queryTextArea; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
95 |
JComponent queryAggregate; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
96 |
JLabel serverLabel; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
97 |
JTextField serverField; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
98 |
JLabel driverLabel; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
99 |
JTextField driverField; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
100 |
JPanel mainPanel; |
2 | 101 |
TableSorter sorter; |
102 |
JDBCAdapter dataBase; |
|
103 |
JScrollPane tableAggregate; |
|
104 |
||
105 |
/** |
|
106 |
* Brigs up a JDialog using JOptionPane containing the connectionPanel. |
|
107 |
* If the user clicks on the 'Connect' button the connection is reset. |
|
108 |
*/ |
|
109 |
void activateConnectionDialog() { |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
110 |
if (JOptionPane.showOptionDialog(tableAggregate, connectionPanel, |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
111 |
ConnectTitle, |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
112 |
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
113 |
null, ConnectOptionNames, ConnectOptionNames[0]) == 0) { |
2 | 114 |
connect(); |
115 |
frame.setVisible(true); |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
116 |
} else if (!frame.isVisible()) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
117 |
System.exit(0); |
2 | 118 |
} |
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* Creates the connectionPanel, which will contain all the fields for |
|
123 |
* the connection information. |
|
124 |
*/ |
|
125 |
public void createConnectionDialog() { |
|
126 |
// Create the labels and text fields. |
|
127 |
userNameLabel = new JLabel("User name: ", JLabel.RIGHT); |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
128 |
userNameField = new JTextField("app"); |
2 | 129 |
|
130 |
passwordLabel = new JLabel("Password: ", JLabel.RIGHT); |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
131 |
passwordField = new JTextField("app"); |
2 | 132 |
|
133 |
serverLabel = new JLabel("Database URL: ", JLabel.RIGHT); |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
134 |
serverField = new JTextField("jdbc:derby://localhost:1527/sample"); |
2 | 135 |
|
136 |
driverLabel = new JLabel("Driver: ", JLabel.RIGHT); |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
137 |
driverField = new JTextField("org.apache.derby.jdbc.ClientDriver"); |
2 | 138 |
|
139 |
||
140 |
connectionPanel = new JPanel(false); |
|
141 |
connectionPanel.setLayout(new BoxLayout(connectionPanel, |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
142 |
BoxLayout.X_AXIS)); |
2 | 143 |
|
144 |
JPanel namePanel = new JPanel(false); |
|
145 |
namePanel.setLayout(new GridLayout(0, 1)); |
|
146 |
namePanel.add(userNameLabel); |
|
147 |
namePanel.add(passwordLabel); |
|
148 |
namePanel.add(serverLabel); |
|
149 |
namePanel.add(driverLabel); |
|
150 |
||
151 |
JPanel fieldPanel = new JPanel(false); |
|
152 |
fieldPanel.setLayout(new GridLayout(0, 1)); |
|
153 |
fieldPanel.add(userNameField); |
|
154 |
fieldPanel.add(passwordField); |
|
155 |
fieldPanel.add(serverField); |
|
156 |
fieldPanel.add(driverField); |
|
157 |
||
158 |
connectionPanel.add(namePanel); |
|
159 |
connectionPanel.add(fieldPanel); |
|
160 |
} |
|
161 |
||
162 |
public TableExample() { |
|
163 |
mainPanel = new JPanel(); |
|
164 |
||
165 |
// Create the panel for the connection information |
|
166 |
createConnectionDialog(); |
|
167 |
||
168 |
// Create the buttons. |
|
169 |
showConnectionInfoButton = new JButton("Configuration"); |
|
170 |
showConnectionInfoButton.addActionListener(new ActionListener() { |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
171 |
|
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
172 |
public void actionPerformed(ActionEvent e) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
173 |
activateConnectionDialog(); |
2 | 174 |
} |
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
175 |
}); |
2 | 176 |
|
177 |
fetchButton = new JButton("Fetch"); |
|
178 |
fetchButton.addActionListener(new ActionListener() { |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
179 |
|
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
180 |
public void actionPerformed(ActionEvent e) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
181 |
fetch(); |
2 | 182 |
} |
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
183 |
}); |
2 | 184 |
|
185 |
// Create the query text area and label. |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
186 |
queryTextArea = new JTextArea("SELECT * FROM APP.CUSTOMER", 25, 25); |
2 | 187 |
queryAggregate = new JScrollPane(queryTextArea); |
188 |
queryAggregate.setBorder(new BevelBorder(BevelBorder.LOWERED)); |
|
189 |
||
190 |
// Create the table. |
|
191 |
tableAggregate = createTable(); |
|
192 |
tableAggregate.setBorder(new BevelBorder(BevelBorder.LOWERED)); |
|
193 |
||
194 |
// Add all the components to the main panel. |
|
195 |
mainPanel.add(fetchButton); |
|
196 |
mainPanel.add(showConnectionInfoButton); |
|
197 |
mainPanel.add(queryAggregate); |
|
198 |
mainPanel.add(tableAggregate); |
|
199 |
mainPanel.setLayout(this); |
|
200 |
||
201 |
// Create a Frame and put the main panel in it. |
|
202 |
frame = new JFrame("TableExample"); |
|
203 |
frame.addWindowListener(new WindowAdapter() { |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
204 |
|
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
205 |
@Override |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
206 |
public void windowClosing(WindowEvent e) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
207 |
System.exit(0); |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
208 |
} |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
209 |
}); |
2 | 210 |
frame.setBackground(Color.lightGray); |
211 |
frame.getContentPane().add(mainPanel); |
|
212 |
frame.pack(); |
|
213 |
frame.setVisible(false); |
|
214 |
frame.setBounds(200, 200, 640, 480); |
|
215 |
||
216 |
activateConnectionDialog(); |
|
217 |
} |
|
218 |
||
219 |
public void connect() { |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
220 |
dataBase = new JDBCAdapter( |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
221 |
serverField.getText(), |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
222 |
driverField.getText(), |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
223 |
userNameField.getText(), |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
224 |
passwordField.getText()); |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
225 |
sorter.setModel(dataBase); |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
226 |
} |
2 | 227 |
|
228 |
public void fetch() { |
|
229 |
dataBase.executeQuery(queryTextArea.getText()); |
|
230 |
} |
|
231 |
||
232 |
public JScrollPane createTable() { |
|
233 |
sorter = new TableSorter(); |
|
234 |
||
235 |
//connect(); |
|
236 |
//fetch(); |
|
237 |
||
238 |
// Create the table |
|
239 |
JTable table = new JTable(sorter); |
|
240 |
// Use a scrollbar, in case there are many columns. |
|
241 |
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
|
242 |
||
243 |
// Install a mouse listener in the TableHeader as the sorter UI. |
|
244 |
sorter.addMouseListenerToHeaderInTable(table); |
|
245 |
||
246 |
JScrollPane scrollpane = new JScrollPane(table); |
|
247 |
||
248 |
return scrollpane; |
|
249 |
} |
|
250 |
||
251 |
public static void main(String s[]) { |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
252 |
// Trying to set Nimbus look and feel |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
253 |
try { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
254 |
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
255 |
if ("Nimbus".equals(info.getName())) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
256 |
UIManager.setLookAndFeel(info.getClassName()); |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
257 |
break; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
258 |
} |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
259 |
} |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
260 |
} catch (Exception ex) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
261 |
Logger.getLogger(TableExample.class.getName()).log(Level.SEVERE, |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
262 |
"Failed to apply Nimbus look and feel", ex); |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
263 |
} |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
264 |
|
2 | 265 |
new TableExample(); |
266 |
} |
|
267 |
||
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
268 |
public Dimension preferredLayoutSize(Container c) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
269 |
return origin; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
270 |
} |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
271 |
|
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
272 |
public Dimension minimumLayoutSize(Container c) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
273 |
return origin; |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
274 |
} |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
275 |
|
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
276 |
public void addLayoutComponent(String s, Component c) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
277 |
} |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
278 |
|
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
279 |
public void removeLayoutComponent(Component c) { |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
280 |
} |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
281 |
|
2 | 282 |
public void layoutContainer(Container c) { |
283 |
Rectangle b = c.getBounds(); |
|
284 |
int topHeight = 90; |
|
285 |
int inset = 4; |
|
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
286 |
showConnectionInfoButton.setBounds(b.width - 2 * inset - 120, inset, 120, |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
287 |
25); |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
288 |
fetchButton.setBounds(b.width - 2 * inset - 120, 60, 120, 25); |
2 | 289 |
// queryLabel.setBounds(10, 10, 100, 25); |
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
290 |
queryAggregate.setBounds(inset, inset, b.width - 2 * inset - 150, 80); |
2 | 291 |
tableAggregate.setBounds(new Rectangle(inset, |
8979
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
292 |
inset + topHeight, |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
293 |
b.width - 2 * inset, |
30050c8aea19
7027701: /jfc/TableExample demo needs to be improved
mrkam
parents:
5506
diff
changeset
|
294 |
b.height - 2 * inset - topHeight)); |
2 | 295 |
} |
296 |
} |