0

I have this code to edit contents of already existing JTable:

DefaultTableModel items = new DefaultTableModel();
items.addColumn("qwe1");
items.addColumn("qwe2");
items.addColumn("qwe3");

items.addRow(new Object[]{1,2,3});

jTable1.setModel(items);

But nothing is displayed in the jTable... I can't quite figure out what I am doing wrong.

PS: I know about these: Updating JTable Updating a JTable JTable not updating But that's not exactly what I am trying to do...

Community
  • 1
  • 1
NewProger
  • 2,945
  • 9
  • 40
  • 58
  • 2
    For better help sooner, post an [SSCCE](http://sscce.org/). – Andrew Thompson Nov 30 '13 at 15:25
  • I agree -- there's no way of guessing what might be wrong without more information, preferably an [sscce](http://sscce.org). – Hovercraft Full Of Eels Nov 30 '13 at 15:26
  • From this snippets of code really hard to find the issue. please post more info. Sounds like its not table-model problem – Maxim Shoustin Nov 30 '13 at 15:29
  • @MaximShoustin *"please post more info"* The trouble with that is that it typically leads to dribs and drabs of information that are unrelated to the problem. An SSCCE guarantees all the relevant information is present, and that has already been suggested twice. – Andrew Thompson Nov 30 '13 at 15:31
  • @AndrewThompson: unfortunately, from the OP's prior questions, it appears that he's building his GUI using NetBean's Matisse Swing GUI builder. While this is a useful tool, for folks learning Swing, it inhibits their learning the basics of Swing, and will hinder his ability to create a decent [sscce](http://sscce.org). See [this question](http://stackoverflow.com/questions/20004179/netbeans-add-popup-menu-with-visual-editor) for instance. – Hovercraft Full Of Eels Nov 30 '13 at 15:35
  • To the original poster, for instance, if you built your program by hand, you'd already know that your current problem has absolutely nothing to do with the code you've posted above, that your error lies elsewhere. – Hovercraft Full Of Eels Nov 30 '13 at 15:39
  • @HovercraftFullOfEels I *have* seen code that I'd regard as an SSCCE, that was obviously built using a GUI designer. But then, if the OP cannot manage it, they are on their own (AFAIC). – Andrew Thompson Nov 30 '13 at 15:39
  • 1
    For example, please see [this small program](http://pastebin.com/PxuJ5u74). It is a small SSCCE that holds essentially your code and just a little more code to display the JTable, and shows that your posted code in fact works, that the JTable created this way displays its data as expected. So you are going to have to do some more work on trying to isolate your error. Either that, or try to create and post an [sscce](http://sscce.org). – Hovercraft Full Of Eels Nov 30 '13 at 16:06
  • See also [*Initial Threads*](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html). – trashgod Dec 01 '13 at 00:14

0 Answers0