List of utility methods to do JDialog
javax.swing.JDialog | getRootJDialog(java.awt.Component c) get Root J Dialog java.awt.Component root = javax.swing.SwingUtilities.getRoot(c); if (root instanceof javax.swing.JDialog) { return (javax.swing.JDialog) root; } else { return null; |
void | initialiseFrame(JDialog frame, JScrollPane viewport) initialise Frame frame.add(viewport);
frame.setSize(1100, 800);
frame.setLocation(new Point(200, 100));
frame.setModal(true);
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setVisible(true);
|
boolean | isInsideScreen(JDialog component) Checks if component is inside the screen bounds boolean inside; Rectangle virtualBounds = getVirtualBounds(); inside = virtualBounds.contains(component.getBounds()); return inside; |
void | jointButton(JDialog frame, final JButton button) Allows to relate a dialog to a button frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { button.setEnabled(true); }); |
void | makeJDialogCancellable(final Window w, final Action cancelAction, final boolean disposeOnCancel) Arrange for an existing JDialog or JFrame to close nicely when the ESC key is pressed. JComponent c; if (w instanceof JFrame) { c = (JComponent) ((JFrame) w).getRootPane(); } else if (w instanceof JDialog) { c = (JComponent) ((JDialog) w).getRootPane(); } else { throw new IllegalArgumentException("The window argument has to be either a JFrame or JDialog." + " You provided a " + (w == null ? null : w.getClass().getName())); ... |
void | messageDialog(String string, JDialog parentDialog) message Dialog JOptionPane.showMessageDialog(parentDialog, string); |
void | openDialog(final JDialog dialog) Opens Swing dialog SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dialog.setVisible(true); }); |
void | poseInsideScreen(JDialog component) Poses component inside the screen bounds Rectangle componentBounds = component.getBounds(); Rectangle screenBounds = getVirtualBounds(); Point newLocation; int newLocationX; int newLocationY; if (!isInsideScreen(component)) { if (componentBounds.getX() < 0) newLocationX = 0; ... |
void | positionDialogInContainer(JDialog dialog, Container frame, int horizontal, int vertical) position Dialog In Container Dimension prefSize = dialog.getPreferredSize(); java.awt.Point parentLocation = frame.getLocationOnScreen(); Dimension parentSize = frame.getSize(); int x = parentLocation.x + (parentSize.width - prefSize.width) / 2; int y = parentLocation.y + (parentSize.height - prefSize.height) / 2; switch (horizontal) { case SwingConstants.WEST: x = parentLocation.x; ... |
void | renderDialog(JDialog thedialog, String szMessage, int noffsetx, int noffsety) Calls renderDialog with Help in the title window for a dialog renderDialog(thedialog, szMessage, noffsetx, noffsety, "Help");
|