LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Java: How do I use "\t" in a JMenuItem? (https://www.linuxquestions.org/questions/programming-9/java-how-do-i-use-%5Ct-in-a-jmenuitem-335631/)

LUB997 06-21-2005 01:37 AM

Java: How do I use "\t" in a JMenuItem?
 
Trying to make Java menu items that look like the following:

Code:

New...
Open...        Enter
Move...        F7
Copy...        F8

etc., but the problem I am having is that when I use "\t" in the code, the tabs don't show up in the menu when I actually run the program. My output looks like the following:

New...
Open...Enter
Move...F7
Copy...F8

I tried spaces instead, and that works, but it looks really sloppy.

Here is an example of my code:

JMenuItem moveItem = new JMenuItem("Move...\t\t\tF7");
moveItem.setMnemonic('M');
fileMenu.add(moveItem);


Does anybody know how to make "\t" work?

enemorales 06-21-2005 02:17 AM

Hi,

I think that you want accelerators. Take a look at this page:

http://www.java2s.com/ExampleCode/Sw...celerators.htm

Good luck!


All times are GMT -5. The time now is 02:05 AM.