1 44 45 package org.jfree.ui; 46 47 import java.awt.BasicStroke ; 48 import java.awt.BorderLayout ; 49 import java.awt.Stroke ; 50 import java.awt.event.ActionEvent ; 51 import java.awt.event.ActionListener ; 52 53 import javax.swing.JComboBox ; 54 import javax.swing.JPanel ; 55 56 61 public class StrokeChooserPanel extends JPanel { 62 63 64 private JComboBox selector; 65 66 73 public StrokeChooserPanel(final StrokeSample current, final StrokeSample[] available) { 74 setLayout(new BorderLayout ()); 75 this.selector = new JComboBox (available); 76 this.selector.setSelectedItem(current); 77 this.selector.setRenderer(new StrokeSample(new BasicStroke (1))); 78 add(this.selector); 79 this.selector.addActionListener(new ActionListener () { 81 public void actionPerformed(final ActionEvent evt) { 82 getSelector().transferFocus(); 83 } 84 }); 85 } 86 87 88 93 protected final JComboBox getSelector() 94 { 95 return selector; 96 } 97 98 103 public Stroke getSelectedStroke() { 104 final StrokeSample sample = (StrokeSample) this.selector.getSelectedItem(); 105 return sample.getStroke(); 106 } 107 108 } 109 | Popular Tags |