Results 1 to 1 of 1
-
How to Focus Next Component Sample
Java Code:import java.awt.Container; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; public class NextComponentSample { public static void main(String args[]) { JFrame frame = new JFrame("Next Component Sample"); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(3, 3)); int COUNT = 9; JButton components[] = new JButton[COUNT]; for (int i = 0; i < COUNT; i++) { JButton button = new JButton("" + (i + 1)); components[i] = button; contentPane.add(button); } // Reverse tab order for (int i = 0; i < COUNT; i++) { System.out.println(components[i].getText() + ":" + components[(i + COUNT - 1) % COUNT].getText()); components[i].setNextFocusableComponent(components[(i + COUNT - 1) % COUNT]); } frame.setSize(300, 200); frame.setVisible(true); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Similar Threads
-
set focus to the textfield
By paty in forum New To JavaReplies: 2Last Post: 07-09-2010, 08:28 AM -
how to focus to another JTextfield?
By birdofprey in forum AWT / SwingReplies: 2Last Post: 04-09-2008, 01:08 PM -
add JToolTip on focus gained forJTextField
By ismailsaleh in forum AWT / SwingReplies: 6Last Post: 02-01-2008, 12:02 PM -
JTable Focus Traversal
By helios_lie in forum AWT / SwingReplies: 1Last Post: 12-20-2007, 10:27 AM -
Focus
By Marty in forum AWT / SwingReplies: 1Last Post: 05-31-2007, 02:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks