Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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 707 times)
0 Members and 1 Guest are viewing this topic.
Offline Zushii

Senior Newbie





« Posted 2011-04-07 20: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 Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


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

Tried invalidating the component or forcing repaint?

Kev

Offline Zushii

Senior Newbie





« Reply #2 - Posted 2011-04-08 16: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 15: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 17: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.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (26 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (34 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!