| A Dialog is a window with a title that is usually associated to a Frame.
Example:
Dialog dlg = new Dialog("Dialog Test");
dlg.setBounds(25, 25, 600, 400);
final TextField tBox = new TextField();
tBox.setBounds(25, 25, 150, 20);
dlg.getChildren().add(tBox);
final Button btn1 = new Button("Add Text");
btn1.setBounds(200, 20, 100, 30);
dlg.getChildren().add(btn1);
final Button btn2 = new Button("Numeric Mask");
btn2.setBounds(310, 20, 100, 30);
dlg.getChildren().add(btn2);
final Button btn3 = new Button("Right Align");
btn3.setBounds(420, 20, 100, 30);
dlg.getChildren().add(btn3);
ActionListener clickListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
Button btn = (Button) e.getSource();
if (btn == btn1) {
tBox.setText(tBox.getText() + "913JQP-");
} else if (btn == btn2) {
tBox.setEditMask("#########");
} else if (btn == btn3) {
tBox.setAlignX(AlignX.RIGHT);
}
}
};
btn1.addActionListener(Button.ACTION_CLICK, clickListener);
btn2.addActionListener(Button.ACTION_CLICK, clickListener);
btn3.addActionListener(Button.ACTION_CLICK, clickListener);
Divider dv = new Divider();
dv.setBounds(25, 70, 550, 5);
dlg.getChildren().add(dv);
final TextArea ta = new TextArea();
ta.setBounds(25, 100, 350, 200);
dlg.getChildren().add(ta);
Button btn4 = new Button("Add Text");
btn4.setBounds(420, 100, 100, 30);
dlg.getChildren().add(btn4);
btn4.addActionListener(Button.ACTION_CLICK, new ActionListener() {
public void actionPerformed(ActionEvent e) {
ta.setText(ta.getText() + "913JQP-");
}
});
dlg.setVisible(true);
author: Joshua J. Gertzen |