choosing linestyles with a combobox



hi,

I'm trying to let a user choose a linestyle (that is several predefined dash patterns) by selecting one out of a combobox. I try to display a preview line in each item of the combo.
The problem here is that only the selected element is painted and visible, while the dropdown list displays nothing.


Here's my cell renderer, I hope anyone knows something to solve this one. I suspect paint() is only done for the selected item but I have no clue how to solve it :(

Thanks!

private class LineCellRenderer extends JLabel implements ListCellRenderer {
	private float[] value;
	private JTextField width;
	
	public LineCellRenderer(JTextField width) {
	  super();
	  setOpaque(true);
	  this.width = width;
	}
	
	public Component getListCellRendererComponent(JList list, Object value,
	  int index, boolean isSelected, boolean cellHasFocus) {
	  this.value = (float[])value;
	  return this;
	}
		
	public void paint(Graphics g) {
	  Graphics2D g2 = (Graphics2D)g;
	  super.paint(g);

BasicStroke bStroke = new BasicStroke(Integer.valueOf(width.getText()), BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 5, value, 0);
Line2D line = new Line2D.Double(2, getHeight()/2, getWidth()-4, getHeight()/2);
g2.setColor(Color.BLACK);
g2.setStroke(bStroke);
g2.draw(line);
}
}
.




Relevant Pages

  • Re: Problem: combobox, table lookup, adding new record
    ... My form prompts for the date, then the store where I purchased ... After selecting the store, my next field will display criteria ... >in an item not in the combobox list, and have it be added to the "short ...
    (microsoft.public.access.forms)
  • Re: Missing something basic - Combobox updating table
    ... I have a form that uses the query as the record source called ... The form only contains a single combobox so someone can select ... Selecting any name other than Timmy, ... display the names. ...
    (microsoft.public.access.forms)
  • Re: choosing linestyles with a combobox
    ... I'm trying to let a user choose a linestyle by selecting one out of a combobox. ... private class LineCellRenderer extends JLabel implements ListCellRenderer { ...
    (comp.lang.java.gui)
  • Press Return in ComboBox Messed up Subform Record
    ... I have a combobox in my main form for selecting an ... Then I have a subform to display all of that ... combobox, if I press the Return key, the subform will not ...
    (microsoft.public.access.forms)
  • Update chart after filter
    ... I have a form with a chart and combobox. ... After selecting a field from the ... Now I want the chart to display the ...
    (microsoft.public.access.forms)