From: Erik V. <ev...@us...> - 2012-01-30 12:32:40
|
rails/ui/swing/GameStatus.java | 1 rails/ui/swing/GameUIManager.java | 3 rails/ui/swing/ORUIManager.java | 6 rails/ui/swing/StartRoundWindow.java | 4 rails/ui/swing/elements/CheckBoxDialog.java | 107 ++-------- rails/ui/swing/elements/MessageDialog.java | 78 ------- rails/ui/swing/elements/NonModalDialog.java | 137 ++++++++++++++ rails/ui/swing/elements/RadioButtonDialog.java | 110 ++--------- rails/ui/swing/gamespecific/_1835/StatusWindow_1835.java | 6 rails/ui/swing/gamespecific/_1856/StatusWindow_1856.java | 4 rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java | 5 rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java | 7 12 files changed, 208 insertions(+), 260 deletions(-) New commits: commit 423369599568b645e0a86cbc2dc7d028ee1c3a77 Author: Erik Vos <eri...@xs...> Date: Mon Jan 30 13:29:51 2012 +0100 Refactored nonmodal dialog classes II Added MessageDialog. diff --git a/rails/ui/swing/elements/CheckBoxDialog.java b/rails/ui/swing/elements/CheckBoxDialog.java index 9c30081..0a56e91 100644 --- a/rails/ui/swing/elements/CheckBoxDialog.java +++ b/rails/ui/swing/elements/CheckBoxDialog.java @@ -46,7 +46,7 @@ public class CheckBoxDialog extends NonModalDialog { } @Override - protected void initializeContent() { + protected void initializeInput() { checkBoxes = new JCheckBox[numOptions]; diff --git a/rails/ui/swing/elements/MessageDialog.java b/rails/ui/swing/elements/MessageDialog.java index 47e6353..e4bfe66 100644 --- a/rails/ui/swing/elements/MessageDialog.java +++ b/rails/ui/swing/elements/MessageDialog.java @@ -1,93 +1,21 @@ /* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/ui/swing/elements/MessageDialog.java,v 1.1 2010/01/19 19:49:39 evos Exp $*/ package rails.ui.swing.elements; -import java.awt.*; -import java.awt.event.*; - -import javax.swing.*; - -import org.apache.log4j.Logger; - -import rails.common.LocalText; +import javax.swing.JFrame; /** * A generic dialog for presenting choices by checkboxes. */ -public class MessageDialog extends JDialog implements ActionListener { +public class MessageDialog extends NonModalDialog { private static final long serialVersionUID = 1L; - protected DialogOwner owner = null; - GridBagConstraints gc; - JPanel optionsPane, buttonPane; - JButton okButton; - Dimension size, optSize; - - String message; - - protected static Logger log = - Logger.getLogger(MessageDialog.class.getPackage().getName()); - public MessageDialog(DialogOwner owner, JFrame window, String title, String message) { - super((Frame) null, title, false); // Non-modal - this.owner = owner; - this.message = message; + super (Type.MESSAGE, null, owner, window, title, message, false); initialize(); - pack(); - - // Center on window - int x = (int) window.getLocationOnScreen().getX() - + (window.getWidth() - getWidth()) / 2; - int y = (int) window.getLocationOnScreen().getY() - + (window.getHeight() - getHeight()) / 2; - setLocation(x, y); - - setVisible(true); - toFront(); - } - - private void initialize() { - gc = new GridBagConstraints(); - - optionsPane = new JPanel(); - buttonPane = new JPanel(); - - okButton = new JButton(LocalText.getText("OK")); - okButton.setMnemonic(KeyEvent.VK_O); - okButton.addActionListener(this); - buttonPane.add(okButton); - - getContentPane().setLayout(new GridBagLayout()); - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - optionsPane.setLayout(new GridBagLayout()); - optionsPane.add(new JLabel(message), constraints(0, 0, 10, 10, 10, 10)); - - getContentPane().add(optionsPane, constraints(0, 0, 0, 0, 0, 0)); - getContentPane().add(buttonPane, constraints(0, 1, 0, 0, 0, 0)); - } - - private GridBagConstraints constraints(int gridx, int gridy, int leftinset, - int topinset, int rightinset, int bottominset) { - if (gridx >= 0) gc.gridx = gridx; - if (gridy >= 0) gc.gridy = gridy; - gc.fill = GridBagConstraints.BOTH; - gc.weightx = 0.5; - gc.weighty = 0.5; - if (leftinset >= 0) gc.insets.left = leftinset; - if (topinset >= 0) gc.insets.top = topinset; - if (rightinset >= 0) gc.insets.right = rightinset; - if (bottominset >= 0) gc.insets.bottom = bottominset; - - return gc; - } - public void actionPerformed(ActionEvent arg0) { - setVisible(false); - dispose(); - owner.dialogActionPerformed (); } } diff --git a/rails/ui/swing/elements/NonModalDialog.java b/rails/ui/swing/elements/NonModalDialog.java index fff6538..0fe730c 100644 --- a/rails/ui/swing/elements/NonModalDialog.java +++ b/rails/ui/swing/elements/NonModalDialog.java @@ -39,7 +39,8 @@ public abstract class NonModalDialog extends JDialog implements ActionListener { public static enum Type { CHECKBOX, RADIO, - MESSAGE + MESSAGE, + MIXED } protected static Logger log = @@ -83,7 +84,7 @@ public abstract class NonModalDialog extends JDialog implements ActionListener { optionsPane.setLayout(new GridBagLayout()); optionsPane.add(new JLabel(message), constraints(0, 0, 10, 10, 10, 10)); - initializeContent(); + initializeInput(); getContentPane().add(optionsPane, constraints(0, 0, 0, 0, 0, 0)); getContentPane().add(buttonPane, constraints(0, 1, 0, 0, 0, 0)); @@ -101,7 +102,8 @@ public abstract class NonModalDialog extends JDialog implements ActionListener { setAlwaysOnTop(true); } - protected abstract void initializeContent(); + protected void initializeInput() { + } protected GridBagConstraints constraints(int gridx, int gridy, int leftinset, int topinset, int rightinset, int bottominset) { @@ -129,7 +131,7 @@ public abstract class NonModalDialog extends JDialog implements ActionListener { owner.dialogActionPerformed (); } - protected abstract void processOK (ActionEvent actionEvent); + protected void processOK (ActionEvent actionEvent) {}; - protected abstract void processCancel (ActionEvent actionEvent); + protected void processCancel (ActionEvent actionEvent) {}; } diff --git a/rails/ui/swing/elements/RadioButtonDialog.java b/rails/ui/swing/elements/RadioButtonDialog.java index a40b1a7..1d7cc59 100644 --- a/rails/ui/swing/elements/RadioButtonDialog.java +++ b/rails/ui/swing/elements/RadioButtonDialog.java @@ -35,7 +35,7 @@ public class RadioButtonDialog extends NonModalDialog { } @Override - protected void initializeContent() { + protected void initializeInput() { choiceButtons = new JRadioButton[numOptions]; group = new ButtonGroup(); commit 3d8a7a01e36779e6cf92ce6ea54d720d621d496a Merge: 6716550 6f3e1b3 Author: Erik Vos <eri...@xs...> Date: Mon Jan 30 12:49:33 2012 +0100 Merge branch 'master' of ssh://rails.git.sourceforge.net/gitroot/rails/rails into nonmodal commit 6716550625b1eca8cac294f59c38418d690e44c5 Author: Erik Vos <eri...@xs...> Date: Wed Jan 25 14:18:29 2012 +0100 Refactored non-modal dialog classes. All are now subclasses of a new abstract class NonModalDialog, which contains most of the common code. diff --git a/rails/ui/swing/GameStatus.java b/rails/ui/swing/GameStatus.java index 3e30944..b15bd42 100644 --- a/rails/ui/swing/GameStatus.java +++ b/rails/ui/swing/GameStatus.java @@ -764,6 +764,7 @@ public class GameStatus extends GridPanel implements ActionListener { if (options.size() > 1) { if (startCompany) { RadioButtonDialog dialog = new RadioButtonDialog ( + NonModalDialog.Usage.COMPANY_START_PRICE, gameUIManager, parent, LocalText.getText("PleaseSelect"), diff --git a/rails/ui/swing/GameUIManager.java b/rails/ui/swing/GameUIManager.java index e50d32e..ae71267 100644 --- a/rails/ui/swing/GameUIManager.java +++ b/rails/ui/swing/GameUIManager.java @@ -620,7 +620,8 @@ public class GameUIManager implements DialogOwner { orWindow.setVisible(true); orWindow.toFront(); - CheckBoxDialog dialog = new CheckBoxDialog(this, + CheckBoxDialog dialog = new CheckBoxDialog(NonModalDialog.Usage.EXCHANGE_TOKENS, + this, orWindow, LocalText.getText("ExchangeTokens"), prompt, diff --git a/rails/ui/swing/ORUIManager.java b/rails/ui/swing/ORUIManager.java index db96ac7..b31dd09 100644 --- a/rails/ui/swing/ORUIManager.java +++ b/rails/ui/swing/ORUIManager.java @@ -547,7 +547,8 @@ public class ORUIManager implements DialogOwner { orWindow.setVisible(true); orWindow.toFront(); - CheckBoxDialog dialog = new CheckBoxDialog(this, + CheckBoxDialog dialog = new CheckBoxDialog(NonModalDialog.Usage.SELECT_DESTINATION_COMPANIES, + this, orWindow, LocalText.getText("DestinationsReached"), LocalText.getText("DestinationsReachedPrompt"), @@ -1462,7 +1463,8 @@ public class ORUIManager implements DialogOwner { Bank.format(i * loanAmount)); } } - RadioButtonDialog currentDialog = new RadioButtonDialog (gameUIManager, + RadioButtonDialog currentDialog = new RadioButtonDialog (NonModalDialog.Usage.REPAY_LOANS, + gameUIManager, orWindow, LocalText.getText("Select"), LocalText.getText("SelectLoansToRepay", action.getCompanyName()), diff --git a/rails/ui/swing/StartRoundWindow.java b/rails/ui/swing/StartRoundWindow.java index 4cf1b88..1b9af8a 100644 --- a/rails/ui/swing/StartRoundWindow.java +++ b/rails/ui/swing/StartRoundWindow.java @@ -648,7 +648,9 @@ implements ActionListener, KeyListener, ActionPerformer, DialogOwner { options[i] = Bank.format(spacePerPrice.get(startPrices[i]).getPrice()); } - RadioButtonDialog dialog = new RadioButtonDialog(this, + RadioButtonDialog dialog = new RadioButtonDialog( + NonModalDialog.Usage.COMPANY_START_PRICE, + this, this, LocalText.getText("PleaseSelect"), LocalText.getText("WHICH_START_PRICE", diff --git a/rails/ui/swing/elements/CheckBoxDialog.java b/rails/ui/swing/elements/CheckBoxDialog.java index 910180c..9c30081 100644 --- a/rails/ui/swing/elements/CheckBoxDialog.java +++ b/rails/ui/swing/elements/CheckBoxDialog.java @@ -1,26 +1,18 @@ /* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/ui/swing/elements/CheckBoxDialog.java,v 1.9 2010/06/16 20:59:10 evos Exp $*/ package rails.ui.swing.elements; -import java.awt.*; -import java.awt.event.*; +import java.awt.Dimension; +import java.awt.event.ActionEvent; import javax.swing.*; -import org.apache.log4j.Logger; - -import rails.common.LocalText; - /** * A generic dialog for presenting choices by checkboxes. */ -public class CheckBoxDialog extends JDialog implements ActionListener { +public class CheckBoxDialog extends NonModalDialog { private static final long serialVersionUID = 1L; - protected DialogOwner owner = null; - GridBagConstraints gc; - JPanel optionsPane, buttonPane; - JButton okButton, cancelButton; JCheckBox[] checkBoxes; Dimension size, optSize; ButtonGroup group; @@ -32,22 +24,18 @@ public class CheckBoxDialog extends JDialog implements ActionListener { int chosenOption = -1; boolean hasCancelButton = false; - protected static Logger log = - Logger.getLogger(CheckBoxDialog.class.getPackage().getName()); - - public CheckBoxDialog(DialogOwner owner, JFrame window, String title, String message, + public CheckBoxDialog(Usage usage, DialogOwner owner, JFrame window, String title, String message, String[] options) { - this (owner, window, title, message, options, null, false); + this (usage, owner, window, title, message, options, null, false); } - public CheckBoxDialog(DialogOwner owner, JFrame window, String title, String message, + public CheckBoxDialog(Usage usage, DialogOwner owner, JFrame window, String title, String message, String[] options, boolean[] selectedOptions, boolean addCancelButton) { - super((Frame) null, title, false); // Non-modal - this.owner = owner; - this.message = message; + + super (Type.CHECKBOX, usage, owner, window, title, message, addCancelButton); + this.options = options; this.numOptions = options.length; - this.hasCancelButton = addCancelButton; if (selectedOptions != null) { this.selectedOptions = selectedOptions; } else { @@ -55,84 +43,31 @@ public class CheckBoxDialog extends JDialog implements ActionListener { } initialize(); - pack(); - - // Center on owner - int x = (int) window.getLocationOnScreen().getX() - + (window.getWidth() - getWidth()) / 2; - int y = (int) window.getLocationOnScreen().getY() - + (window.getHeight() - getHeight()) / 2; - setLocation(x, y); - - setVisible(true); - setAlwaysOnTop(true); } - private void initialize() { - gc = new GridBagConstraints(); - - optionsPane = new JPanel(); - buttonPane = new JPanel(); - - okButton = new JButton(LocalText.getText("OK")); - okButton.setMnemonic(KeyEvent.VK_O); - okButton.addActionListener(this); - buttonPane.add(okButton); - - if (hasCancelButton) { - cancelButton = new JButton(LocalText.getText("Cancel")); - cancelButton.setMnemonic(KeyEvent.VK_C); - cancelButton.addActionListener(this); - buttonPane.add(cancelButton); - } - - checkBoxes = new JCheckBox[numOptions]; - - getContentPane().setLayout(new GridBagLayout()); - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - optionsPane.setLayout(new GridBagLayout()); - optionsPane.add(new JLabel(message), constraints(0, 0, 10, 10, 10, 10)); + @Override + protected void initializeContent() { checkBoxes = new JCheckBox[numOptions]; for (int i = 0; i < numOptions; i++) { checkBoxes[i] = - new JCheckBox(options[i], selectedOptions[i]); + new JCheckBox(options[i], selectedOptions[i]); optionsPane.add(checkBoxes[i], constraints(0, 1 + i, 0, 0, 0, 0)); - checkBoxes[i].setPreferredSize(size); + //checkBoxes[i].setPreferredSize(size); } - - getContentPane().add(optionsPane, constraints(0, 0, 0, 0, 0, 0)); - getContentPane().add(buttonPane, constraints(0, 1, 0, 0, 0, 0)); } - private GridBagConstraints constraints(int gridx, int gridy, int leftinset, - int topinset, int rightinset, int bottominset) { - if (gridx >= 0) gc.gridx = gridx; - if (gridy >= 0) gc.gridy = gridy; - gc.fill = GridBagConstraints.BOTH; - gc.weightx = 0.5; - gc.weighty = 0.5; - if (leftinset >= 0) gc.insets.left = leftinset; - if (topinset >= 0) gc.insets.top = topinset; - if (rightinset >= 0) gc.insets.right = rightinset; - if (bottominset >= 0) gc.insets.bottom = bottominset; - - return gc; + @Override + protected void processOK (ActionEvent actionEvent) { + for (int i = 0; i < numOptions; i++) { + selectedOptions[i] = checkBoxes[i].isSelected(); + } } - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource().equals(okButton)) { - for (int i = 0; i < numOptions; i++) { - selectedOptions[i] = checkBoxes[i].isSelected(); - } - } else if (arg0.getSource().equals(cancelButton)) { - // return; - } - setVisible(false); - dispose(); - owner.dialogActionPerformed (); + @Override + protected void processCancel (ActionEvent actionEvent) { + } public String[] getOptions () { diff --git a/rails/ui/swing/elements/NonModalDialog.java b/rails/ui/swing/elements/NonModalDialog.java new file mode 100644 index 0000000..fff6538 --- /dev/null +++ b/rails/ui/swing/elements/NonModalDialog.java @@ -0,0 +1,135 @@ +package rails.ui.swing.elements; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + +import org.apache.log4j.Logger; + +import rails.common.LocalText; + +public abstract class NonModalDialog extends JDialog implements ActionListener { + + private static final long serialVersionUID = 1L; + + protected Type type; + protected Usage usage; + protected DialogOwner owner = null; + protected JFrame window = null; + protected String message; + protected boolean hasCancelButton = false; + + GridBagConstraints gc; + JPanel optionsPane, buttonPane; + JButton okButton, cancelButton; + + public static enum Usage { + REPAY_LOANS, + DESTINATION_REACHED, + BUY_WHICH_TRAIN, + COMPANY_START_PRICE, + EXCHANGE_TOKENS, + SELECT_FOLDING_COMPANIES, + SELECT_DESTINATION_COMPANIES, + SELECT_COMPANY, + SELECT_HOME_STATION + } + + public static enum Type { + CHECKBOX, + RADIO, + MESSAGE + } + + protected static Logger log = + Logger.getLogger(NonModalDialog.class.getPackage().getName()); + + public NonModalDialog(Type type, Usage usage, + DialogOwner owner, JFrame window, String title, String message, + boolean addCancelButton) { + + super((Frame) null, title, false); // Non-modal + this.type = type; + this.usage = usage; + this.owner = owner; + this.window = window; + this.message = message; + hasCancelButton = addCancelButton; + } + + protected final void initialize() { + + gc = new GridBagConstraints(); + + optionsPane = new JPanel(); + buttonPane = new JPanel(); + + okButton = new JButton(LocalText.getText("OK")); + okButton.setMnemonic(KeyEvent.VK_O); + okButton.addActionListener(this); + buttonPane.add(okButton); + + if (hasCancelButton) { + cancelButton = new JButton(LocalText.getText("Cancel")); + cancelButton.setMnemonic(KeyEvent.VK_C); + cancelButton.addActionListener(this); + buttonPane.add(cancelButton); + } + + getContentPane().setLayout(new GridBagLayout()); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + optionsPane.setLayout(new GridBagLayout()); + optionsPane.add(new JLabel(message), constraints(0, 0, 10, 10, 10, 10)); + + initializeContent(); + + getContentPane().add(optionsPane, constraints(0, 0, 0, 0, 0, 0)); + getContentPane().add(buttonPane, constraints(0, 1, 0, 0, 0, 0)); + + pack(); + + // Center on owner + int x = (int) window.getLocationOnScreen().getX() + + (window.getWidth() - getWidth()) / 2; + int y = (int) window.getLocationOnScreen().getY() + + (window.getHeight() - getHeight()) / 2; + setLocation(x, y); + + setVisible(true); + setAlwaysOnTop(true); + } + + protected abstract void initializeContent(); + + protected GridBagConstraints constraints(int gridx, int gridy, int leftinset, + int topinset, int rightinset, int bottominset) { + if (gridx >= 0) gc.gridx = gridx; + if (gridy >= 0) gc.gridy = gridy; + gc.fill = GridBagConstraints.BOTH; + gc.weightx = 0.5; + gc.weighty = 0.5; + if (leftinset >= 0) gc.insets.left = leftinset; + if (topinset >= 0) gc.insets.top = topinset; + if (rightinset >= 0) gc.insets.right = rightinset; + if (bottominset >= 0) gc.insets.bottom = bottominset; + + return gc; + } + + public void actionPerformed(ActionEvent actionEvent) { + if (actionEvent.getSource().equals(okButton)) { + processOK(actionEvent); + } else if (actionEvent.getSource().equals(cancelButton)) { + processCancel (actionEvent); + } + setVisible(false); + dispose(); + owner.dialogActionPerformed (); + } + + protected abstract void processOK (ActionEvent actionEvent); + + protected abstract void processCancel (ActionEvent actionEvent); +} diff --git a/rails/ui/swing/elements/RadioButtonDialog.java b/rails/ui/swing/elements/RadioButtonDialog.java index 5041ed5..a40b1a7 100644 --- a/rails/ui/swing/elements/RadioButtonDialog.java +++ b/rails/ui/swing/elements/RadioButtonDialog.java @@ -1,133 +1,67 @@ /* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/ui/swing/elements/RadioButtonDialog.java,v 1.8 2010/01/31 22:22:34 macfreek Exp $*/ package rails.ui.swing.elements; -import java.awt.*; -import java.awt.event.*; +import java.awt.Dimension; +import java.awt.event.ActionEvent; import javax.swing.*; -import org.apache.log4j.Logger; - -import rails.common.LocalText; - /** * A generic dialog for presenting choices by radio buttons. */ -public class RadioButtonDialog extends JDialog implements ActionListener { +public class RadioButtonDialog extends NonModalDialog { private static final long serialVersionUID = 1L; - GridBagConstraints gc; - JPanel optionsPane, buttonPane; - JButton okButton, cancelButton; + JRadioButton[] choiceButtons; Dimension size, optSize; ButtonGroup group; - DialogOwner owner; - String message; int numOptions; String[] options; int selectedOption; int chosenOption = -1; - protected static Logger log = - Logger.getLogger(RadioButtonDialog.class.getPackage().getName()); - - public RadioButtonDialog(DialogOwner owner, JFrame window, String title, String message, + public RadioButtonDialog(Usage usage, DialogOwner owner, JFrame window, String title, String message, String[] options, int selectedOption) { - super((Frame) null, title, false); // Non-modal - this.owner = owner; - this.message = message; + + super (Type.RADIO, usage, owner, window, title, message, selectedOption < 0); + this.options = options; this.numOptions = options.length; this.selectedOption = selectedOption; initialize(); - pack(); - - // Center on window - int x = (int) window.getLocationOnScreen().getX() - + (window.getWidth() - getWidth()) / 2; - int y = (int) window.getLocationOnScreen().getY() - + (window.getHeight() - getHeight()) / 2; - setLocation(x, y); - - setVisible(true); - setAlwaysOnTop(true); } - private void initialize() { - gc = new GridBagConstraints(); - - optionsPane = new JPanel(); - buttonPane = new JPanel(); - - okButton = new JButton(LocalText.getText("OK")); - okButton.setMnemonic(KeyEvent.VK_O); - okButton.addActionListener(this); - buttonPane.add(okButton); - - if (selectedOption < 0) { - // If an option has been preselected, selection is mandatory. - cancelButton = new JButton(LocalText.getText("Cancel")); - cancelButton.setMnemonic(KeyEvent.VK_C); - cancelButton.addActionListener(this); - buttonPane.add(cancelButton); - } - - choiceButtons = new JRadioButton[numOptions]; - - getContentPane().setLayout(new GridBagLayout()); - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - optionsPane.setLayout(new GridBagLayout()); - // optionsPane.setBorder(BorderFactory.createLoweredBevelBorder()); - optionsPane.add(new JLabel(message), constraints(0, 0, 10, 10, 10, 10)); + @Override + protected void initializeContent() { choiceButtons = new JRadioButton[numOptions]; group = new ButtonGroup(); for (int i = 0; i < numOptions; i++) { choiceButtons[i] = - new JRadioButton(options[i], i == selectedOption); + new JRadioButton(options[i], i == selectedOption); optionsPane.add(choiceButtons[i], constraints(0, 1 + i, 0, 0, 0, 0)); choiceButtons[i].setPreferredSize(size); group.add(choiceButtons[i]); } - - getContentPane().add(optionsPane, constraints(0, 0, 0, 0, 0, 0)); - getContentPane().add(buttonPane, constraints(0, 1, 0, 0, 0, 0)); } - private GridBagConstraints constraints(int gridx, int gridy, int leftinset, - int topinset, int rightinset, int bottominset) { - if (gridx >= 0) gc.gridx = gridx; - if (gridy >= 0) gc.gridy = gridy; - gc.fill = GridBagConstraints.BOTH; - gc.weightx = 0.5; - gc.weighty = 0.5; - if (leftinset >= 0) gc.insets.left = leftinset; - if (topinset >= 0) gc.insets.top = topinset; - if (rightinset >= 0) gc.insets.right = rightinset; - if (bottominset >= 0) gc.insets.bottom = bottominset; - - return gc; - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource().equals(okButton)) { - for (int i = 0; i < numOptions; i++) { - if (choiceButtons[i].isSelected()) { - chosenOption = i; - break; - } + @Override + protected void processOK(ActionEvent arg0) { + for (int i = 0; i < numOptions; i++) { + if (choiceButtons[i].isSelected()) { + chosenOption = i; + break; } - } else if (arg0.getSource().equals(cancelButton)) { - chosenOption = -1; } - this.setVisible(false); - this.dispose(); - owner.dialogActionPerformed(); + } + + @Override + protected void processCancel(ActionEvent arg0) { + chosenOption = -1; } public synchronized int getSelectedOption() { diff --git a/rails/ui/swing/gamespecific/_1835/StatusWindow_1835.java b/rails/ui/swing/gamespecific/_1835/StatusWindow_1835.java index d1bf925..aed46cc 100644 --- a/rails/ui/swing/gamespecific/_1835/StatusWindow_1835.java +++ b/rails/ui/swing/gamespecific/_1835/StatusWindow_1835.java @@ -11,8 +11,7 @@ import rails.game.special.ExchangeForShare; import rails.game.specific._1835.*; import rails.ui.swing.GameUIManager; import rails.ui.swing.StatusWindow; -import rails.ui.swing.elements.CheckBoxDialog; -import rails.ui.swing.elements.ConfirmationDialog; +import rails.ui.swing.elements.*; public class StatusWindow_1835 extends StatusWindow { @@ -88,7 +87,8 @@ public class StatusWindow_1835 extends StatusWindow { ((ExchangeForShare)(company.getSpecialProperties().get(0))).getShare() ); } - currentDialog = new CheckBoxDialog (gameUIManager, + currentDialog = new CheckBoxDialog (NonModalDialog.Usage.SELECT_FOLDING_COMPANIES, + gameUIManager, this, LocalText.getText("Select"), LocalText.getText("SelectCompaniesToFold", diff --git a/rails/ui/swing/gamespecific/_1856/StatusWindow_1856.java b/rails/ui/swing/gamespecific/_1856/StatusWindow_1856.java index 884c516..b48d117 100644 --- a/rails/ui/swing/gamespecific/_1856/StatusWindow_1856.java +++ b/rails/ui/swing/gamespecific/_1856/StatusWindow_1856.java @@ -9,6 +9,7 @@ import rails.game.RoundI; import rails.game.action.*; import rails.game.specific._1856.CGRFormationRound; import rails.ui.swing.StatusWindow; +import rails.ui.swing.elements.NonModalDialog; import rails.ui.swing.elements.RadioButtonDialog; import rails.util.Util; @@ -99,7 +100,8 @@ public class StatusWindow_1856 extends StatusWindow { + "<br>" + message; } - RadioButtonDialog currentDialog = new RadioButtonDialog (gameUIManager, + RadioButtonDialog currentDialog = new RadioButtonDialog (NonModalDialog.Usage.REPAY_LOANS, + gameUIManager, this, LocalText.getText("1856MergerDialog", action.getCompanyName()), message, diff --git a/rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java b/rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java index 70ce9df..81e816d 100644 --- a/rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java +++ b/rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java @@ -8,6 +8,7 @@ import rails.game.PublicCompanyI; import rails.game.action.MergeCompanies; import rails.game.action.PossibleAction; import rails.ui.swing.GameStatus; +import rails.ui.swing.elements.NonModalDialog; import rails.ui.swing.elements.RadioButtonDialog; /** @@ -69,7 +70,9 @@ public class GameStatus_18EU extends GameStatus { } } - RadioButtonDialog dialog = new RadioButtonDialog (gameUIManager, + RadioButtonDialog dialog = new RadioButtonDialog ( + NonModalDialog.Usage.SELECT_COMPANY, + gameUIManager, parent, LocalText.getText("PleaseSelect"), LocalText.getText("SelectCompanyToMergeMinorInto", diff --git a/rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java b/rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java index b881a5f..5c17748 100644 --- a/rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java +++ b/rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java @@ -10,6 +10,7 @@ import rails.game.Stop; import rails.game.action.MergeCompanies; import rails.game.specific._18EU.StartCompany_18EU; import rails.ui.swing.GameUIManager; +import rails.ui.swing.elements.NonModalDialog; import rails.ui.swing.elements.RadioButtonDialog; public class GameUIManager_18EU extends GameUIManager { @@ -72,7 +73,8 @@ public class GameUIManager_18EU extends GameUIManager { "Minor " + minor.getName() + " " + minor.getLongName(); } - dialog = new RadioButtonDialog (this, + dialog = new RadioButtonDialog (NonModalDialog.Usage.SELECT_FOLDING_COMPANIES, + this, statusWindow, LocalText.getText("PleaseSelect"), LocalText.getText( @@ -91,7 +93,8 @@ public class GameUIManager_18EU extends GameUIManager { for (int i = 0; i < options.length; i++) { options[i] = cities.get(i).toString(); } - dialog = new RadioButtonDialog (this, + dialog = new RadioButtonDialog (NonModalDialog.Usage.SELECT_HOME_STATION, + this, statusWindow, LocalText.getText("PleaseSelect"), LocalText.getText( |