|
-
activating mnemonic keys on my buttons
Hi
I have setup mnemonic keys on all my buttons and now want to try and get them to do something - at the moment this is just writing a string to the console, but eventually it will be calling another method.
For example, one of my buttons has:
startButton = new javax.swing.JButton();
startButton.setBackground(buttonColour);
startButton.setFont(new java.awt.Font("MS Sans Serif", 1, 16));
startButton.setForeground(buttonFontColour);
startButton.setMnemonic('s');
startButton.setToolTipText("Start new search");
startButton.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
startButton.setText("START SEARCH");
startButton.setPreferredSize(new java.awt.Dimension(160, 25));
gamePanel.add(startButton);
I have been looking this up for the past three hours and am now a bit lost!
I have looked up the KeyListener and then tried using the keyTyped or the keyPressed method. I now see that perhaps I should alter the line startButton.setMnemonic('s'); to something like startButton.setMnemonic(KeyEvent.VK_S);
I also want it to accept upper or lowercase.
Can anyone help with this please?
Similar Threads
-
By spudmasher in forum ASP.NET
Replies: 3
Last Post: 07-03-2005, 11:59 PM
-
By Sunil Menon in forum .NET
Replies: 0
Last Post: 07-01-2002, 02:46 AM
-
By Michael \(michka\) Kaplan in forum VB Classic
Replies: 8
Last Post: 06-07-2002, 09:23 PM
-
By Julian Hevia in forum VB Classic
Replies: 0
Last Post: 07-18-2001, 05:11 PM
-
By Julian Hevia in forum VB Classic
Replies: 0
Last Post: 07-18-2001, 05:11 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks