Layout Issue
Hi,
My problem is as follows :
There is a parent Panel which has aGridBagLayout.
Inside that panel several other panels are added .
All these panels implement aGridLayout.
However there is one panel in this list which implements aGridBagLayOut. This panel constitutes of a JButton in the first row,a JText in the second row and Four elements (Three JButtons,One JComboBox)
in the third row.All the rows are set equal height.But the middle row gets compressed and gets smaller in height than the other
two rows.The source code however sets all the height to be the same across this panel for all elements.
Please help.
[701 byte] By [
rm76a] at [2007-10-2 23:45:57]

I have attached the code and marked in bold where the issue occours. Please help.
** **********The show gang panel is being change to gridbagbaglayout ********************************/
GridBagLayout gridbag_gng = new GridBagLayout();
GridBagConstraints gc_gng = new GridBagConstraints();
JPanel gangs=new JPanel();
gangs.setLayout(gridbag_gng );
gangs.setBorder(new LineBorder(Color.black,1,false));
gangs.setForeground(PlanBoardStyleSheet.PANELFG);
gangs.setBackground(PlanBoardStyleSheet.PANELBG);
gc_gng.fill = GridBagConstraints.BOTH;
gc_gng.insets=new Insets(1,1,1,1);
gc_gng.weightx = 1.0;
gc_gng.weighty = 1.0;
JButton btnShowGangs=new JButton("Show Gangs");
btnShowGangs.setFont(PlanBoardStyleSheet.makeFont(null,null,null));
btnShowGangs.setForeground(PlanBoardStyleSheet.BUTTONFG);
btnShowGangs.setBackground(PlanBoardStyleSheet.BUTTONBG);
btnShowGangs.addActionListener(listener);
gc_gng.gridx =0;
gc_gng.gridy = 0;
gc_gng.gridwidth = 4;
gc_gng.gridheight = 1;
gridbag_gng.setConstraints(btnShowGangs,gc_gng);
gangs.add(btnShowGangs);
JTextField txtGangs=new JTextField(10);
txtGangs.setFont(PlanBoardStyleSheet.makeFont(null,null,null));
txtGangs.setForeground(PlanBoardStyleSheet.TEXTBOXFG);
txtGangs.setBackground(PlanBoardStyleSheet.TEXTBOXBG);
hmTSPanel.put("Gangs",txtGangs);
gc_gng.gridx =0;
gc_gng.gridy = 1;
gc_gng.gridwidth = 4;
gc_gng.gridheight = 1;
gridbag_gng.setConstraints(txtGangs,gc_gng);
gangs.add(txtGangs);
JLabel lblViewDt=new JLabel("View Date:");
lblViewDt.setFont(PlanBoardStyleSheet.makeFont(null,null,null));
lblViewDt.setForeground(PlanBoardStyleSheet.LABELFG);
lblViewDt.setBackground(PlanBoardStyleSheet.LABELBG);
gc_gng.gridx =0;
gc_gng.gridy = 2;
gc_gng.gridwidth = 1;
gc_gng.gridheight = 1;
gridbag_gng.setConstraints(lblViewDt,gc_gng);
gangs.add(lblViewDt);
JButton viewDt=null;
if(container.getSelectedViewDt()==null || "".equals(container.getSelectedViewDt()))
{
Calendar cal=Calendar.getInstance(TimeZone.getTimeZone("GMT"),Locale.UK);
cal.setTime(new Date());
viewDt=new JButton(cal.get(Calendar.DATE)+"-"+month[cal.get(Calendar.MONTH)]+"-"+cal.get(Calendar.YEAR));
container.setSelectedViewDt(cal.get(Calendar.DATE)+"-"+month[cal.get(Calendar.MONTH)]+"-"+cal.get(Calendar.YEAR));
container.setLastSelectedViewDt(cal.get(Calendar.DATE)+"-"+month[cal.get(Calendar.MONTH)]+"-"+cal.get(Calendar.YEAR));
}
else
{
viewDt=new JButton(container.getSelectedViewDt());
}
if(listener!=null)
viewDt.addActionListener(listener);
viewDt.setFont(PlanBoardStyleSheet.makeFont(null,null,null));
viewDt.setForeground(PlanBoardStyleSheet.BUTTONFG);
viewDt.setBackground(PlanBoardStyleSheet.BUTTONBG);
container.setBtnViewDt(viewDt);
gc_gng.gridx =1;
gc_gng.gridy = 2;
gc_gng.gridwidth = 1;
gc_gng.gridheight = 1;
gridbag_gng.setConstraints(viewDt,gc_gng);
gangs.add(viewDt);
String viewTimeArr[]=new String[96];
String strStartTime="00:00";
int endHr=0;
int endMin=0;
for(int rowNum=0;rowNum<96;rowNum++)
{
endHr = rowNum/4;
endMin = rowNum%4 * 15;
strStartTime=(endHr<10?"0"+endHr:""+endHr)+":"+(endMin<10?"0"+endMin:""+endMin);
viewTimeArr[rowNum] = strStartTime ;
}
JComboBox cmbViewTime=new JComboBox(viewTimeArr);
cmbViewTime.setFont(PlanBoardStyleSheet.makeFont(null,null,null));
cmbViewTime.setForeground(PlanBoardStyleSheet.CMBBOXFG);
cmbViewTime.setBackground(PlanBoardStyleSheet.CMBBOXBG);
if(container.getFocusableTime()==null)
{
container.setFocusableTime("06:00");
cmbViewTime.setSelectedItem("06:00");
}
else
{
cmbViewTime.setSelectedItem(container.getFocusableTime());
}
cmbViewTime.addActionListener(listener);
container.setCmbViewTime(cmbViewTime);
gc_gng.gridx =2;
gc_gng.gridy = 2;
gc_gng.gridwidth = 1;
gc_gng.gridheight = 1;
gridbag_gng.setConstraints(cmbViewTime,gc_gng);
gangs.add(cmbViewTime);
JButton btnShow=new JButton("Refresh");
btnShow.setFont(PlanBoardStyleSheet.makeFont(null,null,null));
btnShow.setForeground(PlanBoardStyleSheet.BUTTONFG);
btnShow.setBackground(PlanBoardStyleSheet.BUTTONBG);
btnShow.addActionListener(listener);
gc_gng.gridx =3;
gc_gng.gridy = 2;
gc_gng.gridwidth = 1;
gc_gng.gridheight = 1;
gridbag_gng.setConstraints(btnShow,gc_gng);
gangs.add(btnShow);
rm76a at 2007-7-14 16:30:24 >
