Results 1 to 3 of 3
Thread: Cursor controlling?
- 01-30-2011, 09:05 PM #1
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
Cursor controlling?
I am stuck in a simple problem.Please anyone help me.
I am giving a simple code.After run the code two JTextField appear in a JFrame.After writing something,pressing ENTER,the text will be displayed.
Java Code:///NewClass.java import javax.swing.*; import java.awt.*; import javax.swing.JScrollPane; import javax.swing.JOptionPane; import java.sql.*; import java.util.*; import javax.swing.text.*; import java.awt.event.*; import java.util.Calendar; class getkeyboard{ JTextField a,b; JFrame frm; Container cnt; public getkeyboard(){ frm=new JFrame("Keyboard"); cnt=frm.getContentPane(); frm.setLayout(null); a=new JTextField(); b=new JTextField(); frm.add(a); frm.add(b); a.setBounds(20,20,100,30); b.setBounds(20,70,100,30); a.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { System.out.println(a.getText()); }} ); b.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { System.out.println(b.getText()); }} ); frm.setVisible(true); frm.setSize(300,300); } } public class NewClass{ public static void main(String ayu[]){ try{ getkeyboard adfdf=new getkeyboard(); }catch(Exception e){} } }
But, I am in a need of that when I press ENTER in a JTEXTFIELD,the cursur should go to the next JTextField [like pressing the TAB]
How to do that??
- 01-31-2011, 02:20 AM #2
requestFocus() or requestFocusInWindow()
- 01-31-2011, 05:19 AM #3
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
Similar Threads
-
Controlling cmd from java...HELP!!
By eponcedeleon in forum Advanced JavaReplies: 12Last Post: 02-23-2010, 06:33 PM -
change the mouse cursor - crosshair cursor
By cassysumandak in forum New To JavaReplies: 1Last Post: 09-28-2009, 01:57 AM -
Controlling the running os process
By Muralidharan in forum Threads and SynchronizationReplies: 1Last Post: 03-26-2009, 07:03 AM -
Controlling loop using next button
By cassysumandak in forum New To JavaReplies: 25Last Post: 03-22-2009, 03:04 PM -
controlling GC
By ravian in forum EclipseReplies: 2Last Post: 01-03-2008, 08:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks