|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--uic.widgets.StandardDialog
A replacement for all you usages of JDialog. This class provides a dialog for your panel, including a set of buttons and all the things you would normally manually configure in JDialog.
Below two examples of a standard dialog with a selection of buttons
OK/Apply/Cancel dialog
OK/Cancel with Defaults
Simple usage:
FontSelection content = new FontSelection(selected);
StandardDialog diag = new StandardDialog(parent, "Select font", StandardDialog.OK_CANCEL);
diag.setComponent(content);
if(diag.show() == StandardDialog.BUTTON_OK) {
return content.getFont();
}
return selected;
The StandardDialog also allows extra buttons like 'Apply' and 'Help'. The way to handle the events in your application when the user presses one of these is simple;
final FontSelection content = new FontSelection();
content.setFont(selected);
StandardDialog diag = new StandardDialog(parent, "Select font", StandardDialog.OK_CANCEL | StandardDialog.BUTTON_DEFAULTS);
diag.setComponent(content);
diag.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
content.setFont(selected);
}
});
// the show follows here just like above.
| Field Summary | |
static int |
BUTTON_APPLY
|
static int |
BUTTON_CANCEL
|
static int |
BUTTON_DEFAULTS
|
static int |
BUTTON_HELP
|
static int |
BUTTON_OK
|
protected JDialog |
internalDialog
|
static int |
OK_APPLY_CANCEL
|
static int |
OK_CANCEL
|
| Constructor Summary | |
StandardDialog(Window owner,
String title,
boolean modal,
int type)
Create an invisible dialog with an optional owner, title and buttons. |
|
StandardDialog(Window owner,
String title,
int type)
Convinience constructor for a modal dialog |
|
| Method Summary | |
void |
addActionListener(ActionListener listener)
Add a listener to listen for non-closing buttons. |
void |
addToolbar(JToolBar toolbar,
int side)
Place a toolbar on the dialog. |
protected void |
buttonPressedSlot(int type)
|
Rectangle |
getBounds()
During or after showing you can query the rectangle of the dialog. |
Point |
getLocation()
During or after showing you can query the location of the dialog. |
Dimension |
getSize()
During or after showing you can query the size of the dialog. |
protected void |
positionDialog(boolean move)
Place the dialog on screen. |
void |
setComponent(Component c)
Place a Component on your dialog. |
int |
show()
Convenience method for the next version. |
int |
show(Point location,
Dimension size)
Show the dialog at the given location. |
int |
show(Rectangle dialogBounds)
Convenience method for the above version. |
uic.TranslationInterface |
translate()
Overload this method to provide translations... |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int BUTTON_OK
public static final int BUTTON_CANCEL
public static final int BUTTON_APPLY
public static final int BUTTON_DEFAULTS
public static final int BUTTON_HELP
public static final int OK_CANCEL
public static final int OK_APPLY_CANCEL
protected JDialog internalDialog
| Constructor Detail |
public StandardDialog(Window owner,
String title,
int type)
public StandardDialog(Window owner,
String title,
boolean modal,
int type)
OK_CANCEL and OK_APPLY_CANCEL are convinience variables to group much used variables together.
After creating the dialog do a setComponent() and a show()
owner - The owner should either be a JFrame or a JDialog extending
class (such as another StandardDialog). It can also be null.title - the name the dialog will get.modal - true for a modal dialog, false for one that allows other windows to
be active at the same time.type - the buttons that should be at the bottom. If none specified then OK is showed.| Method Detail |
public void setComponent(Component c)
public int show(Point location,
Dimension size)
location - the x and y coordinates on the screen where the dialog should appear, can be null to use parents position.size - a size hint for the dialog, can be null to use default based on the preferredSize.
public int show(Rectangle dialogBounds)
public int show()
public void addToolbar(JToolBar toolbar,
int side)
toolbar - the toolbar to place on the dialogside - the position SwingConstants.TOP, SwingConstants.LEFT,
SwingConstants.BOTTOM and SwingConstants.RIGHT are allowed.protected void positionDialog(boolean move)
move - the user allows us to move the dialog.public Point getLocation()
show(Point, Dimension)public Dimension getSize()
show(Point, Dimension)public Rectangle getBounds()
show(Rectangle)protected void buttonPressedSlot(int type)
public void addActionListener(ActionListener listener)
public uic.TranslationInterface translate()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||