Increase JCheckBox size

How to increase the CheckBox size automatically as window size increases?
kishanuAsked:
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.
0
ShamsurizamCommented:
Try to use GridbagLayout. The info about this layout you find it on this website :

http://www.borland.com/jbuilder/news/zd/apr98/ 



0

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
memingCommented:
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
JCheckBox.
 
3. I think you can also override the UIManager's display by
subclassing JCheckBox and writing your own paint() method.
 
0
kgreddyCommented:
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
at NORTH, SOUTH, EAST,WEST and CETER
positions.

/*
            A basic implementation of the JFrame class.
*/

import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;

public class verman extends com.sun.java.swing.JFrame
{
      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.
            //{{INIT_CONTROLS
            getContentPane().setLayout(new BorderLayout());
            setSize(405,305);
            setVisible(false);
            JComboBox1.setSelectedIndex(4);
            JComboBox1.addActionListener(new comboEventHandler());
            getContentPane().add(JComboBox1, BorderLayout.NORTH);
            JComboBox1.setBounds(108,24,157,23);
            
            JButton1.setText("close");
            JButton1.setActionCommand("close");
            JButton1.setBounds(120,240,140,30);
            JButton1.addActionListener(new buttonEventHandler());
            getContentPane().add(JButton1,BorderLayout.SOUTH);

            
            //}}

            //{{INIT_MENUS
            //}}
            
            

      }
      
            
      class comboEventHandler implements ActionListener
      {
          public void actionPerformed(ActionEvent e)
          {
                 //Write your code here  
            }
          
      }
      
      class buttonEventHandler implements ActionListener
      {
          public void actionPerformed(ActionEvent e)
          {
             System.exit(0);
            
            
          }
          
      }
      
      
      public verman(String sTitle)
      {
            this();
            setTitle(sTitle);
      }

      public void setVisible(boolean b)
      {
            if (b)
                  setLocation(50, 50);
            super.setVisible(b);
      }

      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();

            super.addNotify();

            if (frameSizeAdjusted)
                  return;
            frameSizeAdjusted = true;

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

      // Used by addNotify
      boolean frameSizeAdjusted = false;

      //{{DECLARE_CONTROLS
      String [] verNames = {"option1", "option2", "option3","option4","option5" };
      com.sun.java.swing.JComboBox JComboBox1 = new com.sun.java.swing.JComboBox(verNames);
      com.sun.java.swing.JButton JButton1 = new com.sun.java.swing.JButton();
      //}}

      //{{DECLARE_MENUS
      //}}

}
0
kgreddyCommented:
Try using Border layout you can achieve
resizing of the combobox when you increase
the window size
0
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
Java

From novice to tech pro — start learning today.