Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (542)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (604)
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 761 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:

1  
2  
3  
4  
5  
6  
    @Action
    public void addDialog() {
        newAufgabe na = new newAufgabe();
        na.addDialog(txtText.getText(),cbWho.getSelectedItem()+"");
        this.setVisible(false);
    }


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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
  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
        listDialog.setListData(listdata);
     }


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: 221
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


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

Tried invalidating the component or forcing repaint?

Kev

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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Elsealabs (9 views)
2014-12-28 10:39:27

CopyableCougar4 (16 views)
2014-12-28 02:10:29

BurntPizza (20 views)
2014-12-27 22:38:51

Mr.CodeIt (13 views)
2014-12-27 04:03:04

TheDudeFromCI (18 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (93 views)
2014-12-09 22:41:13

BurntPizza (114 views)
2014-12-08 04:46:31
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
java-gaming.org 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‑gaming.org
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!