3333import java .math .BigDecimal ;
3434import java .util .ArrayList ;
3535import java .util .Collections ;
36- import java .util .Iterator ;
3736import java .util .List ;
3837import java .util .prefs .BackingStoreException ;
3938import java .util .prefs .Preferences ;
@@ -57,8 +56,7 @@ public class MainFrame extends JFrame {
5756 private static final long serialVersionUID = -5149326446698624828L ;
5857
5958 private static String version ;
60-
61- private final JMenuBar menuBar ;
59+
6260 private final JTabbedPane customRollTab ;
6361 private final JLabel statusBar ;
6462
@@ -68,9 +66,9 @@ public class MainFrame extends JFrame {
6866
6967 private final AboutDialog aboutDialog ;
7068
71- private List <CustomRollPanel > rollPanels = new ArrayList <CustomRollPanel >();
69+ private List <CustomRollPanel > rollPanels = new ArrayList <>();
7270
73- private List <RollListener > rollListeners = new ArrayList <RollListener >();
71+ private final List <RollListener > rollListeners = new ArrayList <>();
7472
7573 private static final String EXPRESSION_SYNTAX =
7674 "bags (non cumulative rolls):\n "
@@ -105,7 +103,7 @@ public MainFrame() {
105103 }
106104
107105 String credits = "" ;
108- String version = "" ;
106+ String version ;
109107 Image logo = null ;
110108 try {
111109 credits = new String (FileUtil .loadResource ("java/net.rptools.dicetool.dicetool/credits.html" ));
@@ -117,9 +115,9 @@ public MainFrame() {
117115 ioe .printStackTrace ();
118116 }
119117 aboutDialog = new AboutDialog (this , logo , credits );
120-
121118
122- menuBar = new JMenuBar ();
119+
120+ JMenuBar menuBar = new JMenuBar ();
123121 JMenu menu = new JMenu ("File" );
124122 menu .setMnemonic ('F' );
125123 menuBar .add (menu );
@@ -168,8 +166,6 @@ public void actionPerformed(ActionEvent e) {
168166 private static final long serialVersionUID = -7511992886537497232L ;
169167
170168 public void actionPerformed (ActionEvent e ) {
171- RowListModel tm = resultPanel .getTableModel ();
172-
173169 JOptionPane .showMessageDialog (
174170 MainFrame .this ,
175171 "Random: "
@@ -213,8 +209,7 @@ public void actionPerformed(ActionEvent e) {
213209 panel .add (dicePanel );
214210
215211 customRollTab = new JTabbedPane (JTabbedPane .TOP , JTabbedPane .SCROLL_TAB_LAYOUT );
216- for (Iterator i = rollPanels .iterator (); i .hasNext (); ) {
217- CustomRollPanel rollPanel = (CustomRollPanel ) i .next ();
212+ for (CustomRollPanel rollPanel : rollPanels ) {
218213 customRollTab .add (rollPanel );
219214 }
220215
@@ -282,16 +277,14 @@ public void actionPerformed(ActionEvent e) {
282277 }
283278
284279 public void roll (String definition ) {
285- ExpressionParser parser = new ExpressionParser (resolver );
280+ ExpressionParser parser = new ExpressionParser ();
286281
287282
288283 try {
289284 //List xps = ExpressionFactory.getExpressions(definition, variablePanel.getVariables());
290-
291- for (Iterator i = rollListeners .iterator (); i .hasNext ();) {
292- RollListener l = (RollListener ) i .next ();
293-
294- l .rolled (Collections .singletonList (parser .evaluate (definition ).format ()));
285+
286+ for (RollListener l : rollListeners ) {
287+ l .rolled (Collections .singletonList (parser .evaluate (definition , resolver ).format ()));
295288 }
296289 } catch (ParserException e ) {
297290 JOptionPane .showMessageDialog (this , e .getMessage ());
@@ -397,8 +390,7 @@ public void saveRollPanelPreferences(Preferences rootPrefs) {
397390 prefs .putBoolean ("tabbed" , true );
398391
399392 int index = 0 ;
400- for (Iterator i = rollPanels .iterator (); i .hasNext (); index ++) {
401- CustomRollPanel rollPanel = (CustomRollPanel ) i .next ();
393+ for (CustomRollPanel rollPanel : rollPanels ) {
402394
403395 String name = rollPanel .getName ();
404396 prefs .put ("TabName" + index , name );
@@ -435,12 +427,10 @@ public void exportPreferences(File file, int tabIndex) {
435427
436428 try {
437429 tabPrefs .exportSubtree (new FileOutputStream (file ));
438- } catch (IOException e ) {
439- e .printStackTrace (System .err );
440- } catch (BackingStoreException e ) {
430+ } catch (IOException | BackingStoreException e ) {
441431 e .printStackTrace (System .err );
442432 }
443-
433+
444434 }
445435
446436/* public void convertPreferences() {
0 commit comments