?
Solved

Layout related query

Posted on 2004-08-12
4
Medium Priority
?
239 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
[X]
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
  • 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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

718 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