wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Problem with JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with JTable" Watch "Problem with JTable" New topic
Author

Problem with JTable

Jose Pérez
Greenhorn

Joined: Jul 19, 2009
Posts: 10
Hi,

I´m trying to make the Bingo Game (UK):



I have written two classes, main system, and players.
In the system, I generate the content for the card in a bidimensional array, and send it to the player classes via parameter, in which i get the error. The content is ok, I print it before in console.
The player should show a JTable with the content of that array, I have tested my player JTable with basic examples and everything ok, but now I don´t know what is wrong.



Class Player Code:


And the errors:



Thanks in advance, and apologies for my english (writing from Spain).
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2419
    
    7

Welcome to the Ranch.

The error is pretty obvious: "No such method". So did you type the method correctly?


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10401
    
    8

"sh ranch",
Please check your private messages for an important administrative matter


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

K. Tsang wrote:Welcome to the Ranch.

The error is pretty obvious: "No such method". So did you type the method correctly?

In this case, it's the constructor.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jose Pérez
Greenhorn

Joined: Jul 19, 2009
Posts: 10
K. Tsang wrote:Welcome to the Ranch.

The error is pretty obvious: "No such method". So did you type the method correctly?


Do you mean at the system (main) class?

In it, I call to the player with a button:






Rob Prime wrote:it's the constructor.

In this case, I thought the problem was the missing public at:



but eclipse throws the same error. No idea what´s the mistake.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

A NoSuchMethodError usually means that a class is compiled against one version of a class (Modelodatos) that does have the method / constructor, but the actual class files (Modelodatos.class) doesn't.

Try doing a full rebuild; this should cause all class files to be completely regenerated. Or simply change your Modelodatos class just a bit, enough to cause it to recompile.
Jose Pérez
Greenhorn

Joined: Jul 19, 2009
Posts: 10
Such a thing, it worked



Now the problem is the size, I tried all of this:




But as you can see at the image, width is always the same, but height works perfectly, ¿where I should set the size?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

It's the JScrollPane that makes the GUI so large. So either set the preferred size of the JScrollPane, or of the control it is in.
Mikko Kohtamäki
Ranch Hand

Joined: Dec 13, 2008
Posts: 112
Try setPreferredScrollableViewportSize(new Dimension(300,400)) for your JTable.

From JTable's documentation for setPreferredScrollableViewportSize method @param size
a Dimension object specifying the preferredSize of a JViewport whose view is this table


And this JViewport lays in JScrollPane.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2183
    
    7
Try setPreferredScrollableViewportSize(new Dimension(300,400)) for your JTable.


No need to guess the size:

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2419
    
    7

Or you can just pack the frame = frame.pack();
Jose Pérez
Greenhorn

Joined: Jul 19, 2009
Posts: 10
Hi again, I tried everything and finally fixed it setting the table size and using pack(), thank you very much everybody !

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with JTable