• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with JTable

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The error is pretty obvious: "No such method". So did you type the method correctly?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"sh ranch",
Please check your private messages for an important administrative matter
 
Sheriff
Posts: 22780
131
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

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

Try setPreferredScrollableViewportSize(new Dimension(300,400)) for your JTable.



No need to guess the size:

 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !

 
Watchya got in that poodle gun? Anything for me? Or this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic