 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.mainactions;
22 import java.awt.Component;
23 import java.awt.Dialog.ModalityType;
24 import java.awt.event.WindowEvent;
25 import java.awt.event.WindowListener;
26 import javax.swing.Box;
27 import javax.swing.BoxLayout;
28 import javax.swing.JButton;
29 import javax.swing.JDialog;
30 import javax.swing.JOptionPane;
31 import javax.swing.JPanel;
32 import javax.swing.JTextField;
33 import javax.swing.event.DocumentEvent;
34 import javax.swing.event.DocumentListener;
35 import javax.swing.text.JTextComponent;
40 import net.
sf.japi.swing.action.ActionBuilder;
41 import net.
sf.japi.swing.action.ActionBuilderFactory;
42 import net.
sf.japi.swing.action.ActionMethod;
43 import net.
sf.japi.swing.action.ToggleAction;
44 import org.jetbrains.annotations.NotNull;
45 import org.jetbrains.annotations.Nullable;
57 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
63 private final JOptionPane
optionPane =
new JOptionPane();
100 final JPanel panel =
new JPanel();
101 panel.setLayout(
new BoxLayout(panel, BoxLayout.Y_AXIS));
105 panel.add(Box.createVerticalStrut(5));
106 final ToggleAction skipAdjacentSquaresAction = (ToggleAction)
ACTION_BUILDER.createToggle(
false,
"randomFillSkipAdjacentSquares",
this);
107 panel.add(skipAdjacentSquaresAction.createCheckBox());
112 final DocumentListener documentListener =
new DocumentListener() {
115 public void insertUpdate(@NotNull
final DocumentEvent e) {
120 public void removeUpdate(@NotNull
final DocumentEvent e) {
125 public void changedUpdate(@NotNull
final DocumentEvent e) {
142 public void windowOpened(
final WindowEvent e) {
147 public void windowClosing(
final WindowEvent e) {
152 public void windowClosed(
final WindowEvent e) {
157 public void windowIconified(
final WindowEvent e) {
162 public void windowDeiconified(
final WindowEvent e) {
167 public void windowActivated(
final WindowEvent e) {
174 public void windowDeactivated(
final WindowEvent e) {
194 final JDialog tmpDialog;
198 tmpDialog.getRootPane().setDefaultButton(
okButton);
200 tmpDialog.setModalityType(ModalityType.DOCUMENT_MODAL);
206 tmpDialog.setVisible(
true);
253 return 0 < fillDensity && fillDensity <= 100;
static int parseInt(@NotNull final String s)
Parses an integer string.
RandomFillDialog()
Creates a new instance.
Base package of all Gridarta classes.
Defines common UI constants used in different dialogs.
Displays a dialog asking for parameters for the "random fill" function.
void setRandomFillSkipAdjacentSquares(final boolean skipAdjacentSquares)
Action method for "skip adjacent squares" action.
void randomFillOkay()
Action method to close the dialog with "OK".
static JLabel newLabel(@NotNull final ActionBuilder actionBuilder, @NotNull final String key)
Creates a new JLabel from a resource key.
static final ActionBuilder ACTION_BUILDER
Action Builder to create Actions.
Graphical User Interface of Gridarta.
int getFillDensity()
Returns the fill density.
void randomFillCancel()
Action method to close the dialog with "Cancel".
final JButton cancelButton
The "Cancel" button.
final WindowListener windowListener
The WindowListener attached to dialog to call {} after the dialog has been shown.
boolean isRandomFillSkipAdjacentSquares()
Action method for "skip adjacent squares" action.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
static void setAutoSelectOnFocus(@NotNull final JTextComponent textComponent)
Selects all text of a JTextComponent when the component gains the focus.
boolean isOkButtonEnabled()
Returns whether the "OK" button is enabled.
JDialog dialog
The JDialog instance or.
final JButton okButton
The "OK" button.
Utility class for ActionBuilder related functions.
boolean skipAdjacentSquares
Whether adjacent squares are checked.
void updateOkButton()
Updates the enabled state of the "OK" button depending on the dialog's contents.
Utility class for JTextComponent related functions.
final JTextComponent fillDensityTextField
The text field for specifying the fill density.
boolean showRandomFillDialog(@NotNull final Component parent)
Displays the random fill dialog.
Border DIALOG_BORDER
The Border object to be used when creating dialogs.
Utility class for parsing strings into numbers.
final JOptionPane optionPane
The JOptionPane instance used to create dialogs.