1 Replies - 1147 Views - Last Post: 10 April 2012 - 03:35 PM Rate Topic: -----

#1 Billzhere  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 22-June 11

Clear content from a JTextField <solved>

Posted 10 April 2012 - 03:25 PM

Im making a basic calculator using javax.swing, what method can i used to clear out the content (numbers that the user entered) in the JTextField using an action listener attached to a JButton? I tried .removeAll in my example.
	private class ClearFields implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			c_result.removeAll(); // c_result is the JTextField
		}
	}


This post has been edited by pbl: 10 April 2012 - 03:42 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Clear content from a JTextField <solved>

#2 Billzhere  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 22-June 11

Re: Clear content from a JTextField <solved>

Posted 10 April 2012 - 03:35 PM

View PostBillzhere, on 10 April 2012 - 03:25 PM, said:

Im making a basic calculator using javax.swing, what method can i used to clear out the content (numbers that the user entered) in the JTextField using an action listener attached to a JButton? I tried .removeAll in my example.
	private class ClearFields implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			c_result.removeAll(); // c_result is the JTextField
		}
	}


got it, .setText(""); will reset the field
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1