-
JToolbar problems
Hi,
I wanted to put my toolbar in a GridBagLayout for I can put a ComboBox that
doesn't stretch to the end of the program.
This is what I have:
JLabel eventsLabel = new JLabel("Events:", SwingConstants.LEFT);
comboEvents = new JComboBox();
comboEvents.setEditable(false);
comboEvents.addItem("Test");
GridBagLayout eventLayout = new GridBagLayout();
toolbar.setLayout(eventLayout);
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.NONE;
constraints.anchor = GridBagConstraints.EAST;
constraints.weightx = 0;
constraints.weighty = 0;
constraints.gridx = 0;
constraints.gridy = 0;
constraints.gridwidth = 0;
constraints.gridheight = 0;
toolbar.add(comboEvents, constraints);
JLabel groupsLabel = new JLabel("Groups:", SwingConstants.LEFT);
comboGroups = new JComboBox();
comboGroups.setEditable(false);
comboGroups.addItem("Test");
toolbar.add(eventsLabel);
toolbar.add(comboEvents);
content.add(toolbar, BorderLayout.NORTH);
I added the ComboBox to the toolbar twice, that seemed to put it to the far
right of the buttons instead of it being underneath the last ones.
Right now with this code it puts all items in the toolbar in the center;
I would like to have it to the east.
I'm probably just going at this the wrong way.
Also is there a way to get which control (combo box, etc) has focus?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks