This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFrame and JTable

 
Cathy Young
Ranch Hand
Posts: 126
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do not use setBound, it is a deprecated method long time ago.
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
The AbstractTableModel implementation of isCellEditable returns false. I had it in my source and, luckily, noticed that.
Cheers
Torgny
 
Cathy Young
Ranch Hand
Posts: 126
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact what I did is add a ComponentListener to my frmae like this:

Hope this helps
Stephane
 
Cathy Young
Ranch Hand
Posts: 126
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that helps! Thanks, St�phane!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic