• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 459
  • Last Modified:

Left justify JCheckBos in GBL

The followinig code right  justifies checkbox.
how do I left justifies checkbox?
******************************

public void createSinDataPanel() {
      sinDataPanel = new JPanel();
    GridBagLayout layout = new GridBagLayout();
    sinDataPanel.setLayout(layout);

    constraints = new GridBagConstraints();
   
    sinCheckBox = new JCheckBox("Sine plot");
     sinDataPanel.add(sinCheckBox);

  JLabel label = new JLabel("need put 4 JLabels and 4 JTextFields");
  label1.setHorizontalAlignment(JLabel.CENTER);
  TitledBorder titled = new TitledBorder("Title");
  label.setBorder(titled);

   //-----------------------------------------
  arrageComponent(sinCheckBox, 0, 0, 1, 1);
  sinDataPanel.add(sinCheckBox, constraints);

  arrageComponent(label, 0, 1, 1, 1);
  sinDataPanel.add(label, constraints);

 
  }
0
dkim18
Asked:
dkim18
  • 3
3 Solutions
 
zzynxSoftware engineerCommented:
add

         constraints.anchor = GridBagConstraints.WEST;

before you call

         sinDataPanel.add(sinCheckBox, constraints);
0
 
mmuruganandamCommented:
constraints.anchor = GridBagConstraints.LINE_START

would be right one to be used at this occasion.  As the labels are going to be in the line.
0
 
zzynxSoftware engineerCommented:
java help of BorderLayout.LINE_START:

The component goes at the beginning of the line direction for the layout.
***For Western, left-to-right and top-to-bottom orientations, this is equivalent to WEST.***
0
 
zzynxSoftware engineerCommented:
Thank you
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now