use of java.awt.Button in project voltdb by VoltDB.
the class ZaurusEditor method actionPerformed.
/**
* <code>actionPerformed</code> method is the main entry point
* which interprets the buttons and initiates the actions.
*
* @param e an <code>ActionEvent</code> value is been sent to ZaurusEditor as ActionListener
*
* <p>The possible events are:<ul> <li>Buttons on the <b>search
* panel:</b> <dl><dt>Search Row<dd> Starts the search of rows in
* the choosen table with the given search words and search
* options. Without any search words, all rows will be found.<br>
* If no row meets the criteria, there will be a message in the
* status line. <dt>New Row<dd> An empty input panel for the
* choosen table is given. Any search words are
* ignored.</dl><li>Buttons on the <b>edit panel:</b><br>Any
* changes to field values on this panel will be updated to the
* table when the actual row is left, i. e. when pressing one of
* the buttons 'Prev', 'Next' or
* 'Search'. <br><dl><dt>Cancel<dd>Any changes to field contents
* are canceled and reset to the previous values.<dt>Prev<dd>Show
* the previous row which meets the search
* criteria.<dt>Next<dd>Show the next row which meets the search
* criteria.<dt>Delete<dd>This button has to be clicked twice and
* the shown row will be deleted from the table<dt>Search<dd>With
* this button a new search is initiated. Any changes made to
* field contents are saved</dl><li>Buttons on the <b>insert
* panel:</b><dl><dt>Cancel Insert<dd>After beginning to fill a
* new row, the insert may be cancelled. The search panel will be
* shown next.<dt>New Insert<dd>The new row is inserted into the
* table and a new empty insert panel is shown.<dt>New
* Search<dd>The new row is inserted into the table and the search
* panel is shown again.</ul>
*/
public void actionPerformed(ActionEvent e) {
Button button = (Button) e.getSource();
if (button == bSearchRow) {
this.resetLastButtonDelete();
// System.out.println("pressed search");
aktHoldNr = getChoosenTableIndex();
// search all rows
int numberOfRows = ((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).searchRows(this.getWords(), (gAllWords.getSelectedCheckbox().getLabel().equals("all")), (gIgnoreCase.getSelectedCheckbox().getLabel().equals("yes")), (gNoMatchWhole.getSelectedCheckbox().getLabel().equals("no")));
String tableName = (String) vHoldTableNames.elementAt(aktHoldNr);
if (numberOfRows > 0) {
lForm.show(pForm, tableName);
lButton.show(pButton, "edit");
bPrev.setEnabled(false);
// if there is more than one row, enable the next button
bNext.setEnabled(numberOfRows != 1);
ZaurusEditor.printStatus("found " + numberOfRows + " rows in table " + tableName);
} else if (numberOfRows == 0) {
ZaurusEditor.printStatus("no rows found in table " + tableName);
// numberOfRows could be -1 as well, if an SQL exception was encountered
}
// end of if (numberOfRows > 0)
} else if ((button == bNewRow)) {
// System.out.println("pressed new");
aktHoldNr = getChoosenTableIndex();
lForm.show(pForm, (String) vHoldTableNames.elementAt(aktHoldNr));
lButton.show(pButton, "insert");
((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).insertNewRow();
} else if (button == bNewInsert) {
this.resetLastButtonDelete();
// new search in edit row
if (((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).saveNewRow()) {
// System.out.println("pressed new insert");
((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).insertNewRow();
}
} else if (button == bNewSearch) {
this.resetLastButtonDelete();
// new search in edit row
if (((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).saveChanges()) {
// System.out.println("pressed new search");
lForm.show(pForm, "search");
lButton.show(pButton, "search");
}
} else if (button == bNewSearch1) {
this.resetLastButtonDelete();
// new search in insert row, succeeds if the saving is successfull
if (((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).saveNewRow()) {
// System.out.println("pressed new search");
lForm.show(pForm, "search");
lButton.show(pButton, "search");
}
} else if ((button == bNext)) {
this.resetLastButtonDelete();
ZaurusEditor.clearStatus();
if (((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).saveChanges()) {
bPrev.setEnabled(true);
if (!((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).nextRow()) {
bNext.setEnabled(false);
}
}
} else if ((button == bPrev)) {
this.resetLastButtonDelete();
ZaurusEditor.clearStatus();
if (((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).saveChanges()) {
bNext.setEnabled(true);
if (!((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).prevRow()) {
bPrev.setEnabled(false);
}
}
} else if ((button == bCancel1)) {
// cancel in edit panel
this.resetLastButtonDelete();
((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).cancelChanges();
} else if ((button == bCancel2)) {
this.resetLastButtonDelete();
// cancel in insert panel, just show the search panel again
lForm.show(pForm, "search");
lButton.show(pButton, "search");
} else if (button == bDelete) {
if (lastButtonDelete) {
// delete and determine follow up actions, see comment in ZaurusTableForm.deleteRow()
switch(((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).deleteRow()) {
case 1:
lForm.show(pForm, "search");
lButton.show(pButton, "search");
break;
case 2:
bPrev.setEnabled(false);
break;
case 3:
bNext.setEnabled(false);
break;
default:
break;
}
// end of switch (((ZaurusTableForm) vHoldForms.elementAt(aktHoldNr)).deleteRow())
lastButtonDelete = false;
} else {
ZaurusEditor.printStatus("Press 'Delete' a second time to delete row.");
lastButtonDelete = true;
}
// end of if (lastButtonDelete)
}
// end of if (button == Rest)
}
use of java.awt.Button in project voltdb by VoltDB.
the class ZaurusDatabaseManager method initGUI.
/**
* Method declaration
*
*/
private void initGUI() {
Panel pQuery = new Panel();
Panel pCommand = new Panel();
// define a Panel pCard which takes four different cards/views:
// tree of tables, command SQL text area, result window and an editor/input form
pCard = new Panel();
layoutCard = new CardLayout(2, 2);
pCard.setLayout(layoutCard);
// four buttons at the top to quickly switch between the four views
butTree = new Button("Tree");
butCommand = new Button("Command");
butResult = new Button("Result");
butEditor = new Button("Editor");
butTree.addActionListener(this);
butCommand.addActionListener(this);
butResult.addActionListener(this);
butEditor.addActionListener(this);
Panel pButtons = new Panel();
pButtons.setLayout(new GridLayout(1, 4, 8, 8));
pButtons.add(butTree);
pButtons.add(butCommand);
pButtons.add(butResult);
pButtons.add(butEditor);
pResult = new Panel();
pQuery.setLayout(new BorderLayout());
pCommand.setLayout(new BorderLayout());
pResult.setLayout(new BorderLayout());
Font fFont = new Font("Dialog", Font.PLAIN, 12);
txtCommand = new TextArea(5, 40);
txtCommand.addKeyListener(this);
txtResult = new TextArea(20, 40);
txtCommand.setFont(fFont);
txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
butExecute = new Button("Execute");
butExecute.addActionListener(this);
pCommand.add("South", butExecute);
pCommand.add("Center", txtCommand);
gResult = new Grid();
setLayout(new BorderLayout());
pResult.add("Center", gResult);
tTree = new Tree();
tTree.setMinimumSize(new Dimension(200, 100));
gResult.setMinimumSize(new Dimension(200, 300));
eEditor = new ZaurusEditor();
pCard.add("tree", tTree);
pCard.add("command", pCommand);
pCard.add("result", pResult);
pCard.add("editor", eEditor);
fMain.add("Center", pCard);
fMain.add("North", pButtons);
doLayout();
fMain.pack();
}
use of java.awt.Button in project jdk8u_jdk by JetBrains.
the class MultimonFullscreenTest method actionPerformed.
public void actionPerformed(ActionEvent ae) {
GraphicsDevice dev = deviceMap.get(ae.getSource());
System.err.println("Setting FS on device:" + dev);
final Window fsWindow;
if (useFSWindow) {
fsWindow = new Window(this, dev.getDefaultConfiguration()) {
public void paint(Graphics g) {
renderDimensions(g, getBounds(), this.getGraphicsConfiguration());
}
};
} else if (useFSDialog) {
fsWindow = new Dialog((Frame) null, "FS Dialog on device " + dev, false, dev.getDefaultConfiguration());
fsWindow.add(new Component() {
public void paint(Graphics g) {
renderDimensions(g, getBounds(), this.getGraphicsConfiguration());
}
});
} else {
fsWindow = new Frame("FS Frame on device " + dev, dev.getDefaultConfiguration()) {
public void paint(Graphics g) {
renderDimensions(g, getBounds(), this.getGraphicsConfiguration());
}
};
if (addHWChildren) {
fsWindow.add("South", new Panel() {
public void paint(Graphics g) {
g.setColor(Color.red);
g.fillRect(0, 0, getWidth(), getHeight());
}
});
fsWindow.add("North", new Button("Button, sucka!"));
}
}
fsWindow.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
done = true;
fsWindow.dispose();
}
}
});
fsWindow.addWindowListener(new WindowHandler());
dev.setFullScreenWindow(fsWindow);
if (dmChange && dev.isDisplayChangeSupported()) {
DisplayMode[] dms = dev.getDisplayModes();
DisplayMode myDM = null;
for (DisplayMode dm : dms) {
if (dm.getWidth() == 800 && dm.getHeight() == 600 && (dm.getBitDepth() >= 16 || dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) && (dm.getRefreshRate() >= 60 || dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN)) {
myDM = dm;
break;
}
}
if (myDM != null) {
System.err.println("Setting Display Mode: " + myDM.getWidth() + "x" + myDM.getHeight() + "x" + myDM.getBitDepth() + "@" + myDM.getRefreshRate() + "Hz on device" + dev);
dev.setDisplayMode(myDM);
} else {
System.err.println("Can't find suitable display mode.");
}
}
done = false;
if (runRenderLoop) {
Thread updateThread = new Thread(new Runnable() {
public void run() {
BufferStrategy bs = null;
if (useBS) {
fsWindow.createBufferStrategy(2);
bs = fsWindow.getBufferStrategy();
}
while (!done) {
if (useBS) {
Graphics g = bs.getDrawGraphics();
renderDimensions(g, fsWindow.getBounds(), fsWindow.getGraphicsConfiguration());
bs.show();
} else {
fsWindow.repaint();
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
if (useBS) {
bs.dispose();
}
}
});
updateThread.start();
}
}
use of java.awt.Button in project jdk8u_jdk by JetBrains.
the class DimensionEncapsulation method run.
@Override
public void run() {
runTest(new Panel());
runTest(new Button());
runTest(new Checkbox());
runTest(new Canvas());
runTest(new Choice());
runTest(new Label());
runTest(new Scrollbar());
runTest(new TextArea());
runTest(new TextField());
runTest(new Dialog(new JFrame()));
runTest(new Frame());
runTest(new Window(new JFrame()));
runTest(new FileDialog(new JFrame()));
runTest(new List());
runTest(new ScrollPane());
runTest(new JFrame());
runTest(new JDialog(new JFrame()));
runTest(new JWindow(new JFrame()));
runTest(new JLabel("hi"));
runTest(new JMenu());
runTest(new JTree());
runTest(new JTable());
runTest(new JMenuItem());
runTest(new JCheckBoxMenuItem());
runTest(new JToggleButton());
runTest(new JSpinner());
runTest(new JSlider());
runTest(Box.createVerticalBox());
runTest(Box.createHorizontalBox());
runTest(new JTextField());
runTest(new JTextArea());
runTest(new JTextPane());
runTest(new JPasswordField());
runTest(new JFormattedTextField());
runTest(new JEditorPane());
runTest(new JButton());
runTest(new JColorChooser());
runTest(new JFileChooser());
runTest(new JCheckBox());
runTest(new JInternalFrame());
runTest(new JDesktopPane());
runTest(new JTableHeader());
runTest(new JLayeredPane());
runTest(new JRootPane());
runTest(new JMenuBar());
runTest(new JOptionPane());
runTest(new JRadioButton());
runTest(new JRadioButtonMenuItem());
runTest(new JPopupMenu());
//runTest(new JScrollBar()); --> don't test defines max and min in
// terms of preferred
runTest(new JScrollPane());
runTest(new JViewport());
runTest(new JSplitPane());
runTest(new JTabbedPane());
runTest(new JToolBar());
runTest(new JSeparator());
runTest(new JProgressBar());
if (!failures.isEmpty()) {
System.out.println("These classes failed");
for (final Component failure : failures) {
System.out.println(failure.getClass());
}
throw new RuntimeException("Test failed");
}
}
use of java.awt.Button in project jdk8u_jdk by JetBrains.
the class ContainerAIOOBE method main.
public static void main(final String[] args) throws Exception {
ZContainer z = new ZContainer();
z.add(new Button());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(z);
oos.flush();
oos.close();
byte[] array = baos.toByteArray();
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(array));
// Reading the object must not throw ArrayIndexOutOfBoundsException
ZContainer zz = (ZContainer) ois.readObject();
if (zz.getComponentCount() != 1) {
throw new Exception("deserialized object must have 1 component");
}
if (!(zz.getComponent(0) instanceof Button)) {
throw new Exception("deserialized object must contain Button component");
}
if (zz.getComponents().length != 0) {
throw new Exception("deserialized object returns non-empty array");
}
System.out.println("Test passed");
}
Aggregations