Please support our Java advertiser: Lunarpages Java Web Hosting
•
•
Join Date: Mar 2006
Posts: 131
Reputation:
Rep Power: 3
Solved Threads: 0
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;
}Similar Threads
Other Threads in the Java Forum
- Adding an Image to a JPanel (Java)
- Creating a "Data" folder in my C: Drive using my Java program (Java)
- Delete button not working on my Java GUI Inventory (Java)
- GUI problem.. (Java)
- How to align components (Java)
- Java GUI JOptionPane.showMessageDialog (Java)
- help!! My applet can't run... Urgent!! (Java)
Other Threads in the Java Forum
- Previous Thread: Read and update a ini file
- Next Thread: need help with for loop
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Threaded Mode