JPanel subPanel = new JPanel(new BorderLayout(), true);
JPanel buttonPanel = new JPanel(new BorderLayout(), true);
Box buttonBox = Box.createHorizontalBox();
JSearchContext jsc = new JSearchContext();
final JFrame w = new JBidFrame("Search Manager");
Container contentPane = w.getContentPane();
contentPane.setLayout(new BorderLayout());
wholePanel.setBorder(BorderFactory.createTitledBorder("Saved Searches"));
wholePanel.add(buildSearchTable(jsc), BorderLayout.CENTER);
//subPanel.setBorder(BorderFactory.createTitledBorder("Add & Execute New Search"));
//subPanel.add(buildAdditionalPanel(), BorderLayout.SOUTH);
buttonBox.add(jsc.makeButton("Search", "Execute"));
buttonBox.add(jsc.makeButton("New"));
buttonBox.add(jsc.makeButton("Edit", "Edit Search"));
buttonBox.add(jsc.makeButton("Enable"));
buttonBox.add(jsc.makeButton("Disable"));
buttonBox.add(Box.createHorizontalGlue());
buttonBox.add(jsc.makeButton("Delete"));
buttonPanel.setBorder(BorderFactory.createLoweredBevelBorder());
buttonPanel.add(buttonBox, BorderLayout.SOUTH);
wholePanel.add(buttonPanel, BorderLayout.SOUTH);
contentPane.add(wholePanel, BorderLayout.CENTER);
contentPane.add(subPanel, BorderLayout.SOUTH);
w.pack();
w.setResizable(true);
w.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
w.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
savePosition();
SearchManager.getInstance().saveSearches();
}
public void windowIconified(WindowEvent we) {
savePosition();
if(Platform.isWindows() && Platform.isTrayEnabled()) {
if(JConfig.queryConfiguration("windows.tray", "true").equals("true") &&
JConfig.queryConfiguration("windows.minimize", "true").equals("true")) {
w.setVisible(false);
}
}
}
public void windowDeiconified(WindowEvent we) {
if(Platform.isWindows() && Platform.isTrayEnabled()) {
if(JConfig.queryConfiguration("windows.tray", "true").equals("true") &&
JConfig.queryConfiguration("windows.minimize", "true").equals("true")) {
w.setState(JFrame.NORMAL);
w.setVisible(true);
}
}
}
});
// Handle escape key to close the dialog
KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
Action escapeAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
savePosition();
w.setVisible(false);
}
};
w.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
w.getRootPane().getActionMap().put("ESCAPE", escapeAction);
return w;
}