Solved

arranging checkbox and border vertically

Posted on 2004-03-31
2
377 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

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…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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 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:

705 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

16 Experts available now in Live!

Get 1:1 Help Now