Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Layout related query

Posted on 2004-08-12
4
Medium Priority
?
241 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 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

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

916 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