The moose likes Swing / AWT / SWT / JFace and the fly likes JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "JComboBox" Watch "JComboBox" New topic
Author

JComboBox

Ian Lockwood
Greenhorn

Joined: Aug 01, 2001
Posts: 22
I am using a JComboBox populated with a Vector. I want the text to be inset from the left edge of the box, at the moment it is tight to the left hand edge for a JTextField I have used Insets
class FormJTextField extends JTextField
{
FormJTextField()
{
setFont( new Font( "Dialog", Font.BOLD, 16 ));
setMargin(new Insets(4, 4, 4, 4));
}
FormJTextField(String tipTxt)
{
setFont( new Font( "Dialog", Font.BOLD, 16 ));
setMargin(new Insets(4, 4, 4, 4));
setToolTipText(tipTxt);
}
}
how do I do this for a JComboBox?


When eating an Elephant take one bite at a time.<p>Ian...........
Anuradha Saravanamuthu
Greenhorn

Joined: Jan 27, 2002
Posts: 5
Hi,
Try with this
combobox.setHorizondalalighnment(jlabel.right);

thanx & regards,
S.A.Radha.
Ian Lockwood
Greenhorn

Joined: Aug 01, 2001
Posts: 22
Thanks for that but the JComboBox does not have a setHorizontalAlignment method.
The combobox is made up of three components a comboboxbutton a CellRendererPane and a JTextField,
I have tried setting the margins for the JTextField and although this setting is set when I do println of the combobox it does not look any different.
More help please
:roll:
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4120

I think this does what you want it to do...



-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Ian Lockwood
Greenhorn

Joined: Aug 01, 2001
Posts: 22
Thats great Nate thanks,
I have tested it in my code and it works a treat
I am a happy man!
 
 
subject: JComboBox
 
Threads others viewed
JComboBox not working properly on a GridBagLayout ??
JTable troubles
retrieving and storing password from and to hashtable
Jtable cells
Calculator - Stacks
developer file tools