Alignment Problem
- From: chester_fried@xxxxxxxxxxx
- Date: 28 Apr 2006 13:42:05 -0700
In this function I'm trying to clear out and refill a panel with
buttons.
I want the buttons to be packed together at the top of the panel but it
keeps drawing them in the center.
Could someone possibly tell me what I'm doing wrong?
public void refreshView(){
removeAll();
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
this.setLayout(gbl);
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.NORTH;
for(int i=0;i<Buttons.size();i++){
gbl.setConstraints((JButton)Buttons.get(i),gbc);
add((JButton)Buttons.get(i));
gbc.gridy++;
}
invalidate();
validate();
repaint();
}
.
- Follow-Ups:
- Re: Alignment Problem
- From: Knute Johnson
- Re: Alignment Problem
- Prev by Date: Re: Using threads to affect probability
- Next by Date: Re: NetBeans IDE not generating Color Print
- Previous by thread: How do I build a Java Application
- Next by thread: Re: Alignment Problem
- Index(es):