Hi everyone,

I am new to Java and more recently Swing. I was wondering if anyone would be able to show me a way of inputting a value into a text box, and being able to use this to calculate a sum for example.

Also I am interested to know how I can disable buttons, such as radio buttons or check boxes when one has been clicked.. would I need to group these together some how?

Thanks in advance, albert :)

Recommended Answers

All 2 Replies

Hi everyone,

I am new to Java and more recently Swing. I was wondering if anyone would be able to show me a way of inputting a value into a text box, and being able to use this to calculate a sum for example.

Also I am interested to know how I can disable buttons, such as radio buttons or check boxes when one has been clicked.. would I need to group these together some how?

Thanks in advance, albert :)

Well Hi,

For inputting anything to a JTextField you need to make use of setText() method.

How?

JTextField tfd = new JTextField();
tfd.addActionListener(this);
tfd.setText("Hello world");

Do write an ActionPerformed method corresponding to an ActionListener class.

setVisible(true) or setVisible(false)
well help you in solving your remaining doubts..

Cheers

Thats really helpful, thanks for your help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.