Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

arranging checkbox and border vertically

Posted on 2004-03-31
Last Modified: 2010-03-31

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

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

    sinCheckBox = new JCheckBox("Sine plot");

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

    JPanel inputPanel = new JPanel();
    TitledBorder title = new TitledBorder("Sine Parameters");

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

Question by:dkim18
  • 2
LVL 37

Expert Comment

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
LVL 37

Accepted Solution

zzynx earned 250 total points
ID: 10730115

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert String matching to regex in java 4 49
runtime exception 2 41
How do I remove an object from a 3 40
jboss 7.1 start up error 1 31
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

840 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