Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 GUI Problem
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SsJBebiGoku




PostPosted: Wed Feb 02, 2005 3:12 pm   Post subject: GUI Problem

Hi,
I can't seem to get my buttons to be visible...the program creates them fine, because you can click them, but for some reason only one appears until you click the others.
Attached are the required files.

Thanks a lot



pressed.GIF
 Description:
 Filesize:  1.15 KB
 Viewed:  3260 Time(s)

pressed.GIF



unpressed.gif
 Description:
 Filesize:  1.1 KB
 Viewed:  3260 Time(s)

unpressed.gif



SetMines.java
 Description:

Download
 Filename:  SetMines.java
 Filesize:  645 Bytes
 Downloaded:  188 Time(s)


MenuHandler.java
 Description:

Download
 Filename:  MenuHandler.java
 Filesize:  4.57 KB
 Downloaded:  227 Time(s)


Button.java
 Description:

Download
 Filename:  Button.java
 Filesize:  1.12 KB
 Downloaded:  164 Time(s)


BoardProperties.java
 Description:

Download
 Filename:  BoardProperties.java
 Filesize:  992 Bytes
 Downloaded:  168 Time(s)


BoardDraw.java
 Description:

Download
 Filename:  BoardDraw.java
 Filesize:  5.6 KB
 Downloaded:  189 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Fri Feb 04, 2005 7:41 pm   Post subject: (No subject)

we dont want to look through all that code.. please pinpoint you problem.
SsJBebiGoku




PostPosted: Sat Feb 05, 2005 11:16 am   Post subject: (No subject)

it should be in the BoardDraw class, probably something to do with drawPlayArea(). the rest of the code is jsut there so that i can run so you can see what the problem is
rizzix




PostPosted: Sat Feb 05, 2005 11:28 am   Post subject: (No subject)

what layout manager are u using?
SsJBebiGoku




PostPosted: Sat Feb 05, 2005 1:28 pm   Post subject: (No subject)

it's using a GridLayout() format
rizzix




PostPosted: Sat Feb 05, 2005 2:25 pm   Post subject: (No subject)

hmm i looked at ur code..

#1: you are not using an MVC architecture/framework. SWING relies on this MVC concept. not using it will result in your programs not working as expected. (swing is the only and most buggiest package in java, not following the MVC framework usually leads to trouble)

#2: your code design is funny... i suggest to rewrite the entire project using a MVC framework.. not only will it make maintainance a lot easier it will also make it eaiser to extend the project.

don be afraid of rewriting it. you have the concept, all you need to do is code it the right way.


basically, the MVC framework requires that the View (ur game board, buttons etc), the Controller ( event handlers etc) and the Model (the game board model: which buttons are mines and which are not etc) to be separated as far as possible. then later on you write a integration code (usually in your App class) to get these 3 things working together.
SsJBebiGoku




PostPosted: Sun Feb 06, 2005 1:37 pm   Post subject: (No subject)

thank you so much. you're a life saver
rizzix




PostPosted: Sun Feb 06, 2005 3:08 pm   Post subject: (No subject)

sarcasm will get u no where. no one here is going to debug a SWING app of such terrible design.

either way here a working model of a similar generic view:
Java:
import java.awt.*;
import javax.swing.*;

public class Test {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        Container cPane = frame.getContentPane();
        cPane.setLayout(new GridLayout(4,4));
        for (int i = 0; i < 4; i++)
            for (int j = 0; j < 4; j++)
                cPane.add(new JButton(i+","+j));
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}



looking through ur code i've noticed u use the co-ordinates to reveal locations of the other squares.. why not just use the row,col info instead? switching from row-col to co-ordinates simply adds in unnecessary complexity in your code.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: