Solved

Left justify JCheckBos in GBL

Posted on 2004-03-31
4
448 Views
Last Modified: 2012-05-04
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
Comment
Question by:dkim18
  • 3
4 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 70 total points
ID: 10730224
add

         constraints.anchor = GridBagConstraints.WEST;

before you call

         sinDataPanel.add(sinCheckBox, constraints);
0
 
LVL 9

Assisted Solution

by:mmuruganandam
mmuruganandam earned 30 total points
ID: 10731042
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
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 70 total points
ID: 10731093
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
 
LVL 37

Expert Comment

by:zzynx
ID: 10755190
Thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Passing list of object to Oracle Database Procedure 3 60
groupNoAdj 7 86
JUnit 4 @Before and @BeforeClass differences 3 48
Java DateChooser? 3 29
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now