Solved

arranging checkbox and border vertically

Posted on 2004-03-31
2
380 Views
Last Modified: 2010-03-31
hi!

I need to arrange checkbox and border vertically, but mine does arrange horizontally.
how do I correct it?

****************************************

 public void createSinDataPanel() {
    //super(new GridLayout(1, 0));
    sinDataPanel = new JPanel();
    GridBagLayout layout = new GridBagLayout();
    sinDataPanel.setLayout(layout);

    constraints = new GridBagConstraints();
    //setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    sinCheckBox = new JCheckBox("Sine plot");
    //sinCheckBox.LEFT_ALIGNMENT();
    sinDataPanel.add(sinCheckBox);


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

//----------------------
    JPanel inputPanel = new JPanel();
    sinDataPanel.add(inputPanel);//---------
    inputPanel.setLayout(layout);
    TitledBorder title = new TitledBorder("Sine Parameters");
    inputPanel.setBorder(title);
    //inputPanel.seth

    JLabel ampLabel = new JLabel("Amplitude: ");
    JLabel periodLabel = new JLabel("Period: ");
    JLabel minXLabel = new JLabel("Min X: ");
    JLabel maxXLabel = new JLabel("Max X: ");
    JLabel cgcLabel = new JLabel("Current Graph Color: ");

    ampTField = new JTextField("1.0", 5);
    periodTField = new JTextField("1.0", 5);
    minXSinTField = new JTextField("0.0", 5);
    maxXSinTField = new JTextField("1.0", 5);

    arrageComponent(ampLabel, 0, 0, 1, 1);
    inputPanel.add(ampLabel, constraints);

    arrageComponent(ampTField, 1, 0, 1, 1);
    inputPanel.add(ampTField, constraints);

    arrageComponent(periodLabel, 0, 1, 1, 1);
    inputPanel.add(periodLabel, constraints);

    arrageComponent(periodTField, 1, 1, 1, 1);
    inputPanel.add(periodTField, constraints);

    arrageComponent(minXLabel, 0, 2, 1, 1);
    inputPanel.add(minXLabel, constraints);

    arrageComponent(minXSinTField, 1, 2, 1, 1);
    inputPanel.add(minXSinTField, constraints);

    arrageComponent(maxXLabel, 0, 3, 1, 1);
    inputPanel.add(maxXLabel, constraints);

    arrageComponent(maxXSinTField, 1, 3, 1, 1);
    inputPanel.add(maxXSinTField, constraints);

    arrageComponent(cgcLabel, 0, 4, 1, 1);
    inputPanel.add(cgcLabel, constraints);

    arrageComponent(cgcLabel, 1, 4, 1, 1);
    inputPanel.add(cgcLabel, constraints);

    arrageComponent(cgcLabel, 0, 5, 1, 1);
   inputPanel.add(cgcLabel, constraints);

    arrageComponent(cgcLabel, 1, 5, 1, 1);
    inputPanel.add(cgcLabel, constraints);

    //JPanel sinInputPanel = new JPanel();
    //GridBagLayout insideLayout = new GridBagLayout();
    // sinInputPanel.setLayout(insideLayout);

  }
0
Comment
Question by:dkim18
  • 2
2 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 10730095
cf. my answer in your other question.

You could also use a BorderLayout and place the checkbox in the north and the titledborder panel in the center
0
 
LVL 37

Accepted Solution

by:
zzynx earned 250 total points
ID: 10730115
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

786 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