RSS Forums RSS
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 704 | Replies: 6 | Thread Tools  Display Modes
Join Date: Mar 2006
Posts: 131
Reputation: degamer106 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
degamer106 degamer106 is offline Offline
Junior Poster

JPanel's size and JButton

  #1  
May 8th, 2008
When I add buttons to a panel, the buttons seem to take a huge amount of space. How do I get rid of the space? For example:

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

public class Tester
{
	public static void main(String[] args)
	{
		JButton dayButton = new JButton("Day");
		JButton weekButton = new JButton("Week");
		JButton monthButton = new JButton("Month");
		JButton leftButton = new JButton("<<");
		JButton rightButton = new JButton(">>");

		JPanel topButtonPanel = new JPanel();
		topButtonPanel.add(dayButton);
		topButtonPanel.add(weekButton);
		topButtonPanel.add(monthButton);

		JPanel bottomButtonPanel = new JPanel();
		bottomButtonPanel.add(leftButton);
		bottomButtonPanel.add(rightButton);

		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));
		buttonPanel.add(topButtonPanel);
		buttonPanel.add(bottomButtonPanel);

		JFrame frame = new JFrame();

		frame.add(buttonPanel);

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
		frame.setVisible(true);
	}
	private static final int FRAME_WIDTH = 1000;
	private static final int FRAME_HEIGHT = 1000;
}
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:19 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC