aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Table size is coming as a full size of a  frame when i used gridlayout, please Help me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Table size is coming as a full size of a  frame when i used gridlayout, please Help me " Watch "Table size is coming as a full size of a  frame when i used gridlayout, please Help me " New topic
Author

Table size is coming as a full size of a frame when i used gridlayout, please Help me

Karan Das
Greenhorn

Joined: Aug 13, 2009
Posts: 1
JFrame newFrame= new JFrame();

newFrame.setLayout(new GridLayout(7, 1));
String[] pId = {"2008-10-05", "2009-10-09", "2009-01-01"};
prptCombo = new JComboBox(pId);
pIdlabel = new JLabel("PrppertyId");
ownerLabel = new JLabel("Owner Details");
ownerTextArea = new JTextArea();
ownerTextArea.setColumns(20);
ownerTextArea.setRows(5);
JPanel newPanel1 = new JPanel();
JPanel newPanel2 = new JPanel();
JPanel newPanel3 = new JPanel();
JPanel newPanel4 = new JPanel();
JPanel newPanel5 = new JPanel();
JPanel newPanel6 = new JPanel();
JPanel newPanel7 = new JPanel();
taxLabel = new JLabel("Tax");


//Adding table area
JTable jTable1 = new JTable();

String[] columnNames = {"2000-01",
"2001-02",
"2002-03",
"2003-04",
"2004-05",
"2005-06",
"2006-07",
"2007-08",
"2008-09",
"2009-10"};

Object[][] data = {
{null, null,
null, null, null, null, null, null, null, null}
};



final JTable table = new JTable(data, columnNames);

table.setPreferredScrollableViewportSize(new Dimension(500, 500));
table.setFillsViewportHeight(true);
JScrollPane scrollPane = new JScrollPane(table);
JScrollPane scrollPane1 = new JScrollPane(ownerTextArea);

//Adding values are panel
newPanel1.add(pIdlabel);
newPanel1.add(prptCombo);
newPanel2.add(ownerLabel);
newPanel2.add(scrollPane1);
//newPanel5.add(taxLabel);


newPanel3.setLayout(new GridLayout(2,1));
scrollPane.setPreferredSize(new Dimension(200, 100));
newPanel3.add(taxLabel);
newPanel3.add(scrollPane);


JFrame frame2=new JFrame();
//adding panels to the frame
newFrame.add(newPanel4);
newFrame.add(newPanel1);
newFrame.add(newPanel2);
// newFrame.add(newPanel7);
// newFrame.add(newPanel5);
newFrame.add(newPanel3);
newFrame.add(newPanel6);

Lou Caudell
Ranch Hand

Joined: Oct 06, 2001
Posts: 32
I didn't notice it in your code here, but it sounds as if you are setting the gbc fill to expand to available space.
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Don't use GridLayout here as it's not a good fit. There are many other layouts available, and I suggest that you practice using them all if you want to make your apps look better. For instance:

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

Karan, next time please Use Code Tags.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Table size is coming as a full size of a frame when i used gridlayout, please Help me