• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

 
Sheriff
Posts: 22753
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Karan, next time please Use Code Tags.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic