7 Replies - 1073 Views - Last Post: 14 April 2011 - 07:25 AM Rate Topic: -----

#1 lnc12  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 268
  • Joined: 21-May 08

JCheckBox - Extend JFrame/JDialog when checked/isSelcted

Posted 13 April 2011 - 07:55 AM

Wuhu new question.
I haven't been able to write this as a sensable google search sentence.
But what I want to is:
1. Have a JFrame/JDialog with a standart size
2. Have a JCheckBox
3. When it is checked - want I to expand the frame in y dircetion, and add some more components to the enlarge "FRAME"

how to do that?
Is This A Good Question/Topic? 0
  • +

Replies To: JCheckBox - Extend JFrame/JDialog when checked/isSelcted

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10595
  • View blog
  • Posts: 39,246
  • Joined: 27-December 08

Re: JCheckBox - Extend JFrame/JDialog when checked/isSelcted

Posted 13 April 2011 - 09:10 AM

Use the JFrame setSize() method, and the add() method for the appropriate Container on your JFrame (like a JPanel). Make sure to revalidate() your JFrame as well.
Was This Post Helpful? 0
  • +
  • -

#3 lnc12  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 268
  • Joined: 21-May 08

Re: JCheckBox - Extend JFrame/JDialog when checked/isSelcted

Posted 13 April 2011 - 10:18 AM

View Postmacosxnerd101, on 13 April 2011 - 10:10 AM, said:

Use the JFrame setSize() method, and the add() method for the appropriate Container on your JFrame (like a JPanel). Make sure to revalidate() your JFrame as well.

But how do I check if the JCheckBox is Checked as soon as I check it ?
Was This Post Helpful? 0
  • +
  • -

#4 mi14chal  Icon User is offline

  • D.I.C Head

Reputation: 81
  • View blog
  • Posts: 202
  • Joined: 11-December 10

Re: JCheckBox - Extend JFrame/JDialog when checked/isSelcted

Posted 13 April 2011 - 10:53 AM

You can use method isSelected() for check the JCheckBox is selected.
Was This Post Helpful? 0
  • +
  • -

#5 lnc12  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 268
  • Joined: 21-May 08

Re: JCheckBox - Extend JFrame/JDialog when checked/isSelcted

Posted 13 April 2011 - 11:34 PM

View Postmi14chal, on 13 April 2011 - 11:53 AM, said:

You can use method isSelected() for check the JCheckBox is selected.


I know that method, but the problem is how do I check if it is check as soon as it is checked ?
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10595
  • View blog
  • Posts: 39,246
  • Joined: 27-December 08

Re: JCheckBox - Extend JFrame/JDialog when checked/isSelcted

Posted 14 April 2011 - 04:11 AM

Add an ActionListener to the JCheckBox. The ActionListener will be triggered as soon as the JCheckBox is clicked.
Was This Post Helpful? 0
  • +
  • -

#7 softwareEngineer()  Icon User is offline

  • D.I.C Head

Reputation: -28
  • View blog
  • Posts: 247
  • Joined: 08-April 11

Re: JCheckBox - Extend JFrame/JDialog when checked/isSelcted

Posted 14 April 2011 - 05:45 AM

Because I am doubting that you know how to use an action listener, I will give you the template I always use:


public class whatever extends JFrame implements  ItemListener
{
//all code and declarations

YOURCHKBOX.addItemListener(this);

public void itemStateChanged(ItemEvent e) 
{
		//What to do when active;
}
}


This post has been edited by softwareEngineer(): 14 April 2011 - 05:47 AM

Was This Post Helpful? 0
  • +
  • -

#8 lnc12  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 268
  • Joined: 21-May 08

Re: JCheckBox - Extend JFrame/JDialog when checked/isSelcted

Posted 14 April 2011 - 07:25 AM

Thanks a million times you 2 - I did not know that I could assign actionlisteners to JCheckBoxs - but I have used them before thanks a million times
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1