Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get focus on a swing button

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

when i run my program in internet explorer,the focus in every button is working like this.i have to click a button with mouse for the first time and then if we press the tab key ,the next buttons are getting the focus.after reaching the last button the focus goes to the browser and it is not coming to the first button again.what i need is i want to get the focus by default in the first button without clicking the mouse and after reaching the last button the focus have to come into the first button automatically.my code is below.please help me.

code:
public class AstMonitor extends JApplet implements ActionListener,Runnable {

Thread astThread;
JButton callback = new JButton("0 Callback");
JButton noanswer = new JButton("2 NoAnswer");

JButton voicemail = new JButton("3 AnsMach ");
public void init() {
resize(150,475);
GridLayout gl;
getContentPane().setLayout(new GridLayout(3,10));


callback.setActionCommand("callback");
callback.addActionListener(this);
this.getContentPane().add(callback);
callback.setMnemonic('c');
callback.setBackground(Color.pink);
noanswer.setActionCommand("noanswer");
noanswer.addActionListener(this);
this.getContentPane().add(noanswer);
noanswer.setMnemonic('w');
noanswer.setBackground(Color.pink);
voicemail.setActionCommand("voicemail");
voicemail.addActionListener(this);
this.getContentPane().add(voicemail);
voicemail.setMnemonic('a');
voicemail.setBackground(Color.pink);
astThread = new Thread(this);
astThread.start();
}

please anyone help me.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!