• Post Reply Bookmark Topic Watch Topic
  • New Topic

cursor setting in text field

 
vrijendra singh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using following code
iterlbl = new JLabel(" Enter Additional No.Of Iter Value ");
iterlbl.setForeground(Color.white);
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 1;
c.gridheight = 1;
gb.setConstraints(iterlbl, c);
iterPnl.add(iterlbl);
itertf = new JTextField(8);
itertf.setText("100");
c.gridx = 1;
c.gridy = 0;
c.gridwidth = 1;
c.gridheight = 1;
c.fill = GridBagConstraints.HORIZONTAL;
itertf.addKeyListener(this);
itertf.addActionListener(this);
itertf.setForeground(Color.black);
gb.setConstraints(itertf, c);
iterPnl.add(itertf);
in the text field the blinking cursor appears before 100. i want it after 100. how can i do..
query is very urgent ..
plz. help..
vrijendr
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vrij,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
Rahul Ekbote
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use the setHorizontalAlignment of JText field. Set appropriate (right)alignment so that the cursor should display at after 100.
 
Sebastiaan Kortleven
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like
mytextfield.setCaretPosition(mytextfield.getText().length())
should work...
gl
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!