Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Gui problem  (Read 1918 times)
0 Members and 1 Guest are viewing this topic.
Offline Zushii

Senior Newbie

« Posted 2011-04-07 18:51:12 »

Okay, I'm trying to make a mission editor.

And I can't get this extremely easy task to work. I don't understand why.

A Mission, has tasks, tasks have dialogs.

Now I open the new tasks window and want to add a Dialog. Which I do by pressing a button.
The Frame opens and I choose whos speaking and the type in the dialog.

I then click finish.

This fires this method:

    public void addDialog() {
        newAufgabe na = new newAufgabe();

And then back in the tasks frame this method is fired.

  public void addDialog(String Text, String Who) {

        dialogs.add(new Dialog(Who,Text));

        listdata = new String[dialogs.size()];

        for (int i=0; i<listdata.length; i++){
            listdata[i] = dialogs.get(i).getWho();

        lblTest.setText(listdata[0]); // this also doesn't do anything. Eventough it should change the Label. The Label doesn't change

Now normally the jlist should be updated. But it seems like java completely ignores the fact that this method exists.
I debugged it and it went though the whole process, it seems to be working just fine. It adds the dialog to the arraylist. it goes into the for-loop. and does what it does.

But the frame does not update not single bit. I hate guis. Or maybe this is just some netbeans related stuff. I'm always having weird simple problems with java in guis.
Offline kevglass

« JGO Spiffy Duke »

Medals: 319
Projects: 25
Exp: 22 years

Coder, Trainee Pixel Artist, Game Reviewer

« Reply #1 - Posted 2011-04-07 19:11:14 »

Tried invalidating the component or forcing repaint?


Offline Zushii

Senior Newbie

« Reply #2 - Posted 2011-04-08 14:43:22 »

The problem is that the Dialog Object is not added to the arraylist.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CaptainJester

JGO Knight

Medals: 12
Projects: 2
Exp: 14 years

Make it work; make it better.

« Reply #3 - Posted 2011-04-11 13:55:06 »

It's hard to tell from your code but are you using JList to display your info? If so the you need to learn how to use a javax.swing.ListModel. By creating your own list model you can notify listeners about changes to the data. Anytime a listmodel is used the JList signs up as a listener for it. Then when you notify listeners the JList will update its appearance.

Any kind of component that supports changing data should always be built with an appropriate model.

JList - ListModel
JTabel - TableModel
JTree - TreeModel

Offline Zushii

Senior Newbie

« Reply #4 - Posted 2011-04-11 15:25:00 »

Sorry I forgot to say that I fixed the problem.

It seems that you need to give the JFrame you open, the JFrame Object that is opening the JFrame, so it doesn't create another jFrame.
Pages: [1]
  ignore  |  Print  

EgonOlsen (59 views)
2018-06-10 19:43:48

EgonOlsen (42 views)
2018-06-10 19:43:44

EgonOlsen (61 views)
2018-06-10 19:43:20

DesertCoockie (240 views)
2018-05-13 18:23:11

nelsongames (142 views)
2018-04-24 18:15:36

nelsongames (141 views)
2018-04-24 18:14:32

ivj94 (883 views)
2018-03-24 14:47:39

ivj94 (144 views)
2018-03-24 14:46:31

ivj94 (795 views)
2018-03-24 14:43:53

Solater (159 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!