Solved

checkbox and border on one tab

Posted on 2004-03-31
6
590 Views
Last Modified: 2008-03-17
hi!

I have an applet and there are JTabbedPane with 6 tabs.
One of them needs to contain one checkbox and titled border and the checkbox should be out side of titled border.

I have func that starts like this:

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

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

My question is do I need to create another panel for checkbox?
I tried but no border appeared.

What layout do I have to use?

For sample, visit the following site, scroll down a bit, and select "Sin Data" tab.
http://webdev.apl.jhu.edu/~rbe/java/Homework4/index.html

Thanks,
0
Comment
Question by:dkim18
  • 4
6 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 10727145
You make your sinDataPanel to have a titled border like this:

     sinDataPanel = new JPanel();
     sinDataPanel.setBorder( BorderFactory.createTitledBorder("Your title") );
     ...



0
 
LVL 37

Expert Comment

by:zzynx
ID: 10727203
Sometimes java is rather straightforward, huh?
;-)
0
 

Author Comment

by:dkim18
ID: 10727728

>>One of them needs to contain one checkbox and titled border and the checkbox should be out side of titled border.
I need to create checkbox out side of border...
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Expert Comment

by:fave_17
ID: 10729549
Add the checkbox and a NEW JPanel to the tab. Then set the border of the NEW JPanel
0
 
LVL 37

Accepted Solution

by:
zzynx earned 250 total points
ID: 10730083

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

    sinCheckBox = new JCheckBox("Sine plot");
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        sinDataPanel.add(sinCheckBox, gridBagConstraints);

     sinParameterPanel = new JPanel();
     sinParameterPanel.setBorder( BorderFactory.createTitledBorder("Sine parameters") );
     gridBagConstraints.gridy = 1;
     sinDataPanel.add(sinParameterPanel, gridBagConstraints);

     than add inside the sinParameterPanel the labels + text fields the way I already told you in another Q.
     
     
     

   
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10732145
Thank you
:)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 “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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

747 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

8 Experts available now in Live!

Get 1:1 Help Now