aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JFrame and JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JFrame and JTable" Watch "JFrame and JTable" New topic
Author

JFrame and JTable

Cathy Young
Ranch Hand

Joined: Mar 02, 2002
Posts: 126
Hi, Guys,
How did you set the size of the JFrame? Did you just hard-code it as like

Is there any way to make it more flexible?
For JTable, how to disable the cells from being editable?
Thanks,
Cathy
Stephane Weber
Ranch Hand

Joined: Mar 07, 2002
Posts: 110
Cathy,
1. It is recommended not to hardcode the frame size. But some people here did it and still got the maximum points.
Personnally, I just set a minimum size (for being sure that the window is always 'usable'), but let the user resize above this minimum size.
You might consider using GridBagLayouts for placing your components inside the Frame, which allows you to resize efficiently the components.
2. You probably implemented a TableModel class for representing your DataInfo objects in the JTable. For this, you extend AbstractTableModel.
One of AbstractTableModel's method, is isCellEditable. You can thus just implement it like this:

Hope this helps,
Stephane
[ October 24, 2002: Message edited by: St�phane Weber ]
Allen Chan
Ranch Hand

Joined: Jun 07, 2002
Posts: 64
do not use setBound, it is a deprecated method long time ago.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
The AbstractTableModel implementation of isCellEditable returns false. I had it in my source and, luckily, noticed that.
Cheers
Torgny
Cathy Young
Ranch Hand

Joined: Mar 02, 2002
Posts: 126
Thanks, guys!
St�phane, if you set the minimum Frame size, you still have to hardcode it, don't you?
When is setBounds (int, int, int, int) deprecated? I did not see it in 1.3.1 API.
I think Torgny is right. Does it mean that we do not have to override isCellEditable() and it should be not editable? I thought this and did not override it, but it just does not work, why?
Thanks,
Cathy
Stephane Weber
Ranch Hand

Joined: Mar 07, 2002
Posts: 110
In fact what I did is add a ComponentListener to my frmae like this:

Hope this helps
Stephane
Cathy Young
Ranch Hand

Joined: Mar 02, 2002
Posts: 126
Yes, that helps! Thanks, St�phane!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame and JTable
 
Similar Threads
JTable
regarding JTable
JTable ........
jtable
JTable Paging