20 package net.sf.gridarta.gui.dialog.newmap;
22 import java.awt.GridBagConstraints;
23 import javax.swing.JPanel;
24 import javax.swing.JTextField;
31 import net.
sf.japi.swing.action.ActionBuilder;
32 import net.
sf.japi.swing.action.ActionBuilderFactory;
33 import org.jetbrains.annotations.NotNull;
34 import org.jetbrains.annotations.Nullable;
52 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
97 protected AbstractMapsizeNewMapDialog(@Nullable
final String widthKey, @Nullable
final String heightKey,
final int defaultWidth,
final int defaultHeight) {
107 protected void addFields(@NotNull
final JPanel panel, @NotNull
final GridBagConstraints gbcLabel, @NotNull
final GridBagConstraints gbcField) {
108 mapWidthField.setText(Integer.toString(widthKey == null ? defaultWidth :
PREFERENCES.getInt(widthKey, defaultWidth)));
109 mapWidthField.setColumns(3);
111 panel.add(mapWidthField, gbcField);
112 mapWidthField.selectAll();
114 mapHeightField.setText(Integer.toString(heightKey == null ? defaultHeight :
PREFERENCES.getInt(heightKey, defaultHeight)));
115 mapHeightField.setColumns(3);
117 panel.add(mapHeightField, gbcField);
118 mapHeightField.selectAll();
137 if (widthKey != null) {
140 if (heightKey != null) {
144 return new Size2D(width, height);
152 final String text = mapWidthField.getText();
154 return width < 1 ? -1 : width;
163 final String text = mapHeightField.getText();
165 return height < 1 ? -1 : height;
174 mapWidthField.setEnabled(enabled);
175 mapHeightField.setEnabled(enabled);
final JTextField mapHeightField
Textfield for the height of the new map.
final int defaultHeight
The default height for new maps.
final String widthKey
The preference key for storing the map width; may be.
int getMapWidth()
Returns the current map width value.
Utility class for parsing strings into numbers.
static final long serialVersionUID
The serial version UID.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
static int parseInt(@NotNull final String s)
Parses an integer string.
GameObjects are the objects based on Archetypes found on maps.
final int defaultWidth
The default width for new maps.
final String heightKey
The preference key for storing the map height; may be.
final JTextField mapWidthField
Textfield for the width of the new map.
void addFields(@NotNull final JPanel panel, @NotNull final GridBagConstraints gbcLabel, @NotNull final GridBagConstraints gbcField)
static final ActionBuilder ACTION_BUILDER
Action Builder.
AbstractMapsizeNewMapDialog(@Nullable final String widthKey, @Nullable final String heightKey, final int defaultWidth, final int defaultHeight)
Creates a new instance.
Utility class for ActionBuilder related functions.
An abstract base class implementing a AbstractNewMapDialog supporting map size input fields...
void addDocumentListener( @NotNull final JTextComponent textComponent)
Watches for text changes in a text component and enables the "OK" button accordingly.
static final Preferences PREFERENCES
Preferences.
Size2D getMapSize()
Validate the map size fields and return the result.
Dialog used to ask the user the properties for the new level.
static JLabel newLabel(@NotNull final ActionBuilder actionBuilder, @NotNull final String key)
Creates a new JLabel from a resource key.
void setMapSizeEnabled(final boolean enabled)
Enables or disables the map size input fields.
Interface for MapArchObjects.
int getMapHeight()
Returns the current map height value.
The class Size2D represents a 2d rectangular area.