Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox  RSS feed

 
Ian Lockwood
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Anuradha Saravanamuthu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try with this
combobox.setHorizondalalighnment(jlabel.right);

thanx & regards,
S.A.Radha.
 
Ian Lockwood
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this does what you want it to do...



-Nate
 
Ian Lockwood
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats great Nate thanks,
I have tested it in my code and it works a treat
I am a happy man!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!