• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to show underlines in JLabel

 
Abhinav Anand
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I want to under line a specific character in a jlabel. For example:
Full Name: <JText Field Here>
Now how can i underline the character "N" in the above label. Actually i want to show that the gui user that on pressing Ctrl + N the full name text field will get focus.
Thanks in advance.
Vishal.
 
ali rafiq
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JLabel lab = new JLabel("<html><u><bold><b1>that call the event</u></bold></b1></html>");
 
ali rafiq
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JLabel lab = new JLabel("<html><u><bold> HOW R U..</u></bold></html>");
 
Thorsten Schenkel
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The conventional way to do this is:
JLabel lab = new JLabel( "Full Name: " );
lab.setDisplayedMnemonic( 'N' );
JTextField field = new JTextField();
lab.setLabelFor( field );
Now you have to do nothing else. Press Alt+N and the text field gets automatically the focus.
It only works for Alt+N and not for Ctrl+N
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!