• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Basic doubts needed for urgency!!!!!

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends
Could someone suggest me how to main tab order in an application?
Regards
Sriram
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By default, TAB and CTRL-TAB move focus forward, and SHIFT-TAB and CTRL-SHIFT-TAB move focus backward.
 
Sri Ram
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
should the ordering of the awt items be according to the tab?
for eg.
textfield 1
textfield 2
textfield 3
textfield 4
be like this what
add(txtField1);
add(txtField2);
add(txtField3);
add(txtField4);
Do you mean to say that this would maintain tab order itself?
How about for combobox then?

 
Renee Zhang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your example works. But you may add jTextField1.setNextFocusableComponent(jTextField3) to change the order. And I found an example from a book for you.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends JFrame {
private JButton button_1 = new NotFocusTraversableButton(),
button_2 = new ButtonThatManagesFocus(),
button_3 = new JButton("regular button"),
button_4 = new JButton("regular button"),
button_5 = new JButton("request focus disable"),
button_6 = new JButton("next focusable component set to manages Focus button");
public Test () {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
JFrame frame = new Test();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
}
private void jbInit () {
Container contentPane = getContentPane();
FocusCycleRootPanel panel = new FocusCycleRootPanel();
button_5.setRequestFocusEnabled(false);
button_6.setNextFocusableComponent(button_2);
panel.add(button_3);
panel.add(button_4);
panel.add(button_5);
contentPane.setLayout(new FlowLayout());
contentPane.add(button_1);
contentPane.add(button_2);
contentPane.add(panel);
contentPane.add(button_6);
}
}
class ButtonThatManagesFocus extends JButton {
public ButtonThatManagesFocus () {
super("Manages Focus");
}
public boolean isManagingFocus () {
return true;
}
public void processComponentKeyEvent (KeyEvent e) {
System.out.println(e);
}
}
class NotFocusTraversableButton extends JButton {
public NotFocusTraversableButton () {
super ("Not Focus Traversable");
}
public boolean isFocusTraversable () {
return false;
}
}
class FocusCycleRootPanel extends JPanel {
public FocusCycleRootPanel () {
setBorder(BorderFactory.createTitledBorder("FocusCycleRoot panel"));
}
public boolean isFocusCycleRoot () {
return true;
}
}

Good luck!
 
Renee Zhang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry. I was in a hurry that I didn't notice you were talking about AWT. In AWT, you may only forward programmatic traversal: Component.transferFocus(). You may find some detail at http://java.sun.com/products/jfc/tsc/articles/javaOne2001/1315/index.html
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic