Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with JTable

 
Jose Pérez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3348
12
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The error is pretty obvious: "No such method". So did you type the method correctly?
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sh ranch",
Please check your private messages for an important administrative matter
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jose Pérez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2539
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try setPreferredScrollableViewportSize(new Dimension(300,400)) for your JTable.


No need to guess the size:

 
K. Tsang
Bartender
Posts: 3348
12
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can just pack the frame = frame.pack();
 
Jose Pérez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again, I tried everything and finally fixed it setting the table size and using pack(), thank you very much everybody !

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic