final JPanel measuresPanel = new JPanel(); JScrollPane scrollPane = new JScrollPane(measuresPanel); scrollPane.getVerticalScrollBar().setUnitIncrement(10); measuresDialog.getContentPane().add(scrollPane);  JButton cancel = new JButton("Cancel"); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { measuresDialog.setVisible(false); } }); JPanel panel = new JPanel(); panel.add(cancel); measuresDialog.getContentPane().add(panel, BorderLayout.SOUTH);  measuresDialog.setPreferredSize(new Dimension(300, 400)); measuresDialog.pack();
	public SettingsDialog(Frame owner) {		super(owner, "Settings");				JPanel content = new JPanel(new GridBagLayout());		content.setBorder(BorderFactory.createEmptyBorder(10,10,20,10));				GridBagConstraints c = new GridBagConstraints();		c.anchor = GridBagConstraints.WEST;				c.insets = new Insets(0,0,10,10);		c.gridy = 0;		content.add(new JLabel("Measure:"), c);		c.insets = new Insets(0,10,0,0);		c.gridy++;		measure = new DescriptiveChooser();		measure.addObject(MEASURES[450]);		//measure.setSelectedIndex(0);		//measure.setPreferredSize(new Dimension(200, measure.getPreferredSize().height));		content.add(measure, c);		c.gridy++;		c.insets = new Insets(10,0,0,0);		c.anchor = GridBagConstraints.EAST;		JButton addMeasure = new JButton("Add measure ...");		content.add(addMeasure, c);		addMeasure.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent e) {				final JDialog measuresDialog = new JDialog();				measuresDialog.setLayout(new BorderLayout());								final JPanel measuresPanel = new JPanel();				JScrollPane scrollPane = new JScrollPane(measuresPanel);				scrollPane.getVerticalScrollBar().setUnitIncrement(10);				measuresDialog.getContentPane().add(scrollPane);								JButton cancel = new JButton("Cancel");				cancel.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent e) {						measuresDialog.setVisible(false);					}				});				JPanel panel = new JPanel();				panel.add(cancel);				measuresDialog.getContentPane().add(panel, BorderLayout.SOUTH);								measuresDialog.setPreferredSize(new Dimension(300, 400));				measuresDialog.pack();				measuresDialog.setVisible(true);								new Thread(new Runnable() {					public void run() {						JTextArea first = null;						measuresPanel.setLayout(new BoxLayout(measuresPanel, BoxLayout.Y_AXIS));						for (int i = 0; i < MEASURES.length; i++) {							final JPanel measurePanel = new JPanel(new BorderLayout());							JTextArea text = new JTextArea();							text.setEditable(false);							text.setLineWrap(true);							text.setWrapStyleWord(true);							text.setOpaque(false);							text.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));														text.append(MEASURES[i].getDescription());							measurePanel.add(text);							JButton add = new JButton("Add");							final int index = i;							add.addActionListener(new ActionListener() {								public void actionPerformed(ActionEvent e) {									measure.addObject(MEASURES[index]);									measuresDialog.setVisible(false);								}							});							measurePanel.add(add, BorderLayout.EAST);							if (first == null) {								first = text;								EventQueue.invokeLater(new Runnable() {									public void run() {										measuresPanel.add(measurePanel);									}								});							} else {								EventQueue.invokeLater(new Runnable() {									public void run() {										JPanel separator = new JPanel();										separator.setPreferredSize(new Dimension(0,5));										measuresPanel.add(separator);										measuresPanel.add(measurePanel);										measuresPanel.revalidate();									}								});							}						}												final JTextArea ffirst = first; // must be final						EventQueue.invokeLater(new Runnable() {							public void run() {								ffirst.setCaretPosition(0);							}						});					}				}).start();			}		});				c.insets = new Insets(15,0,10,10);		c.gridy++;		c.fill = GridBagConstraints.HORIZONTAL;		content.add(new JLabel("Aggregator:"), c);		c.insets = new Insets(0,10,0,0);		c.gridy++;		aggregator = new DescriptiveChooser(AGGREGATORS);		//aggregator.setPreferredSize(new Dimension(200, aggregator.getPreferredSize().height));		content.add(aggregator, c);				getContentPane().add(content);				JPanel buttons = new JPanel(new FlowLayout());		JButton close = new JButton("Close");		close.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent e) {				SettingsDialog.this.setVisible(false);				}		});		buttons.add(close);		getContentPane().add(buttons, BorderLayout.SOUTH);		pack();	}