Solved

Layout related query

Posted on 2004-08-12
4
236 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

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 …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

710 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