Hi, I have a dialog window composed of two panels: a message panel with gridLayout(1,1), and a buttonsPanel with gridLayout(1,3). When the parent application instantiate the dialog with the message, it packs the dialog, and set its visibility to true, then "yesButton.requestFocus()" but the focus is always in the message panel! Could somebody provide any hint on this please? Thanks.
Thanks for trying to help, but that did not work. I tried several other things without success that did not work also. I suspect that the TextArea object is keeping selfishly the focus for itself!
Serge Plourde
Ranch Hand
Joined: Jun 23, 2000
Posts: 140
posted
0
So, I'm going to use a series of text labels in a GridLayout instead, to display multiple lines messages.
Hi Can anybody help me to run the following code in frame. Same coding which i have done for applet executes very well. The problem is with the requestFocus() which works fine with the applet but not with Frame. Here follows the code for applet //<applet code=KeyLDemo_applet width=500 height=500></applet> import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class KeyLDemo_applet extends Applet implements KeyListener { TextField t1,t2; public void init() { add(t1=new TextField(30)); add(t2=new TextField(10)); addKeyListener(this); requestFocus(); } public void keyPressed(KeyEvent ke) { t1.setText("key pressed"); int s=ke.getKeyCode(); char c=ke.getKeyChar(); t1.setText(c+" "+"key pressed"); String s1=ke.getKeyText(s); switch(s) { case KeyEvent.VK_F1: t1.setText(s+": key was pressed: "+s1); break; case KeyEvent.VK_UP: t1.setText(s+": key was pressed: "+s1); break; case KeyEvent.VK_ESCAPE: t1.setText(s+": key was pressed: "+s1); break; } } public void keyReleased(KeyEvent ke) {t1.setText("key released"); } public void keyTyped(KeyEvent ke) {t2.setText("key typed"); } }
Thanking you in advance
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.