Increase JCheckBox size

How to increase the CheckBox size automatically as window size increases?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jan LouwerensSoftware EngineerCommented:
I beleive that this would depend more on the layout manager you're using, and not specifically on the check box itself.
Try to use GridbagLayout. The info about this layout you find it on this website : 


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Don't think it's possible in AWT. Since awt controls are the native OS GUI controls, and OS companies won't like the idea.

If you are using Swing, you can do your own drawing of any control and make it work with the layoutmanagers.

Here are some options you may have as suggested in a newsgroup posting:

1. Write your own subclass of AbstractButton to draw the
checkbox however you want,
2. Write a subclass modifying the UI class for JCheckBox,
and tell the UIManager to use your subclass to display the
3. I think you can also override the UIManager's display by
subclassing JCheckBox and writing your own paint() method.
Here is an examlpe where I used Border layout
and a combo box, and a close button.

Using border layout, you can position your components

            A basic implementation of the JFrame class.

import java.awt.*;
import java.awt.event.*;

public class verman extends
      public verman()
            // This code is automatically generated by Visual Cafe when you add
            // components to the visual environment. It instantiates and initializes
            // the components. To modify the code, only use code syntax that matches
            // what Visual Cafe can generate, or Visual Cafe may be unable to back
            // parse your Java file into its visual environment.
            getContentPane().setLayout(new BorderLayout());
            JComboBox1.addActionListener(new comboEventHandler());
            getContentPane().add(JComboBox1, BorderLayout.NORTH);
            JButton1.addActionListener(new buttonEventHandler());



      class comboEventHandler implements ActionListener
          public void actionPerformed(ActionEvent e)
                 //Write your code here  
      class buttonEventHandler implements ActionListener
          public void actionPerformed(ActionEvent e)
      public verman(String sTitle)

      public void setVisible(boolean b)
            if (b)
                  setLocation(50, 50);

      static public void main(String args[])
            (new verman()).setVisible(true);

      public void addNotify()
            // Record the size of the window prior to calling parents addNotify.
            Dimension size = getSize();


            if (frameSizeAdjusted)
            frameSizeAdjusted = true;

            // Adjust size of frame according to the insets and menu bar
            Insets insets = getInsets();
   menuBar = getRootPane().getJMenuBar();
            int menuBarHeight = 0;
            if (menuBar != null)
                  menuBarHeight = menuBar.getPreferredSize().height;
            setSize(insets.left + insets.right + size.width, + insets.bottom + size.height + menuBarHeight);

      // Used by addNotify
      boolean frameSizeAdjusted = false;

      String [] verNames = {"option1", "option2", "option3","option4","option5" }; JComboBox1 = new; JButton1 = new;


Try using Border layout you can achieve
resizing of the combobox when you increase
the window size
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.