public GlobalAttributes() { setLayout(new BorderLayout()); LabelledList list = new LabelledList(includeAggregationMethodAttributes() ? "Add Data..." : "Redraw"); add(list, BorderLayout.CENTER); if (includeAggregationMethodAttributes()) { NumberTextField stepsField = new NumberTextField(1, true) { public double newValue(double value) { value = (long) value; if (value <= 0) return currentValue; else { interval = (long) value; return value; } } }; list.addLabelled("Every", stepsField); list.addLabelled("", new JLabel("...Timesteps")); String[] optionsLabel = {"Current", "Maximum", "Minimum", "Mean"}; final JComboBox optionsBox = new JComboBox(optionsLabel); optionsBox.setSelectedIndex(aggregationMethod); optionsBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { aggregationMethod = optionsBox.getSelectedIndex(); } }); list.addLabelled("Using", optionsBox); } String[] optionsLabel2 = new String[] { "When Adding Data", "Every 0.1 Seconds", "Every 0.5 Seconds", "Every Second", "Every 2 Seconds", "Every 5 Seconds", "Every 10 Seconds", "Never" }; final JComboBox optionsBox2 = new JComboBox(optionsLabel2); optionsBox2.setSelectedIndex(redraw); optionsBox2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { redraw = optionsBox2.getSelectedIndex(); generator.update(); // keep up-to-date } }); if (includeAggregationMethodAttributes()) list.addLabelled("Redraw", optionsBox2); else list.add(optionsBox2); }