Solved

Layout related query

Posted on 2004-08-12
4
233 Views
Last Modified: 2010-03-31
Hi all,

i have few Jcheckboxes to be added to the left side of a toolbar and some jbuttons
that are to be added at right to same jtoolbar.
The main idea is to use some layout manager that can do this.

Actually iam trying make a Login Window. In that login window i want along with the login and cancel buttons there should be a option for Saving Password (a check box).
So that check box should appear on extreme left side and other 2 buttons on extreme right side. I want to use JToolBar to place the buttons and checkbox

Thanx
0
Comment
Question by:Harpreet79
  • 2
4 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 11781261
Take a look here for some sample code:

http://javaalmanac.com/egs/javax.swing/toolbar_ToolBar.html
0
 

Author Comment

by:Harpreet79
ID: 11781332
hi
actually i tried that example but the layout didnt work the wayi wanted
cud pls suggest some other example
thanx
0
 
LVL 35

Expert Comment

by:girionis
ID: 11781355
0
 
LVL 6

Accepted Solution

by:
expertmb earned 50 total points
ID: 11781450
try this. it may help.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class JToolBarExample1 extends JFrame
                             {
  private JToolBar toolbar;
  private JCheckBox labelBox;

  public static void main(String[] args) {
    new JToolBarExample1();
  }

  public JToolBarExample1() {
    super("JToolBar Example");
    Container content = getContentPane();
    content.setBackground(Color.white);
    toolbar = new JToolBar();
    content.add(toolbar, BorderLayout.SOUTH);
    labelBox = new JCheckBox("Check Box");
    labelBox.setHorizontalAlignment(SwingConstants.CENTER);
    toolbar.add(labelBox);
    //LOOK HERE
    JPanel panel = new JPanel();
    panel.setSize(100, 10);
   //##########
    toolbar.add(panel);
    toolbar.add(new JButton("Login"));
    toolbar.add(new JButton("Cancel"));
    content.add(new JTextArea(10,30), BorderLayout.CENTER);
    pack();
    setVisible(true);
  }

}

mb...
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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

932 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

14 Experts available now in Live!

Get 1:1 Help Now