New Posts  All Forums:Forum Nav:

[Java] Making an application

post #1 of 9
Thread Starter 
First let me define some classes

GUI: whole menu system. gets grid from another class (irrelevant to this problem)
Main: calls a new gui and displays it


So I'm having a little problem creating an application to run.

Here is what I get when I run the GUI under java beans:34rakn6.png

This is what I get when I create a new GUI and use the setVisible(boolean) command:
33uwlub.png

When I create a new instance of the GUI class and make it visible, the buttons become large and do not retain their color pre defined. What could I do to fix this? Thanks!
Quote:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSplitPane;


public class GUI extends JFrame implements ActionListener
{

public int colorSelected;

private static final long serialVersionUID = 1L;
private JMenuBar jJMenuBar = null;
private JMenu File = null;
private JMenu Options = null;
private JMenu Difficulty = null;
private JRadioButtonMenuItem ChooseRadioButton = null;
private JMenuItem NewGame = null;
private JMenuItem Exit = null;
private JRadioButton Impossible = null;
private JRadioButton Hard = null;
private JRadioButton Medium = null;
private JRadioButton Easy = null;
private JMenu Help = null;
private JMenuItem HowToPlay = null;
private JMenuItem About = null;
private JPanel jPanel = null;
private JSplitPane jSplitPane = null;
private JPanel jContentPane2 = null;
private JPanel jPanel2 = null;
private JPanel jPanelGame=null;
private JButton Redbutton = null;
private JButton Bluebutton = null;
private JButton Purplebutton = null;
private JButton Yellowbutton = null;
private JButton GreenButton = null;
private int numMovesLeft=20;
private JPanel jPanel3 = null;
private JLabel jLabel = null;
private ButtonGroup DifficultyMenu = null;
public Draw draw= new Draw();
public Draw changeDifficulty = new Draw(); // @jve:decl-index=0:
int easySize;
int mediumSize;
int hardSize;
int impossibleSize;
int easyMoves;
int mediumMoves;
int hardMoves;
int impossibleMoves;


/**
* This is the default constructor
*/
public GUI()
{

super();
jPanelGame=draw.GetPanel();
initialize();



}

public static void main(String[] args) {
new GUI();
}


/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(491, 353);
this.setContentPane(getJPanel());
this.setJMenuBar(getJJMenuBar());
this.setTitle("FloodIt! by Kris Balisciano and Parker Heyl");
}

/**
* This method initializes jJMenuBar
*
* @return javax.swing.JMenuBar
*/
private JMenuBar getJJMenuBar() {
if (jJMenuBar == null) {
jJMenuBar = new JMenuBar();
jJMenuBar.setLayout(new BoxLayout(getJJMenuBar(), BoxLayout.X_AXIS));
jJMenuBar.add(getFile());
jJMenuBar.add(getOptions());
jJMenuBar.add(getHelp());
}
return jJMenuBar;
}

/**
* This method initializes File
*
* @return javax.swing.JMenu
*/
private JMenu getFile() {
if (File == null) {
File = new JMenu();
File.setText("File");
File.add(getNewGame());
File.add(getExit());
}
return File;
}

/**
* This method initializes Options
*
* @return javax.swing.JMenu
*/
private JMenu getOptions() {
if (Options == null) {
Options = new JMenu();
Options.setText("Options");
Options.add(getDifficulty());
}
return Options;
}

/**
* This method initializes Difficulty
*
* @return javax.swing.JMenu
*/
private JMenu getDifficulty() {
if (Difficulty == null) {
Difficulty = new JMenu();
Difficulty.setText("Difficulty");
Difficulty.add(getChooseRadioButton());
Difficulty.add(getImpossible());
Difficulty.add(getHard());
Difficulty.add(getMedium());
Difficulty.add(getEasy());
DifficultyMenu = new ButtonGroup();
DifficultyMenu.add(getChooseRadioButton());
DifficultyMenu.add(getImpossible());
DifficultyMenu.add(getHard());
DifficultyMenu.add(getMedium());
DifficultyMenu.add(getEasy());
}
return Difficulty;
}

/**
* This method initializes ChooseRadioButton
*
* @return javax.swing.JRadioButtonMenuItem
*/
private JRadioButtonMenuItem getChooseRadioButton() {
if (ChooseRadioButton == null) {
ChooseRadioButton = new JRadioButtonMenuItem();
ChooseRadioButton.setText("Please choose one:");
}
return ChooseRadioButton;
}

/**
* This method initializes Pause
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getNewGame() {
if (NewGame == null) {
NewGame = new JMenuItem();
NewGame.setText("New Game");
}
return NewGame;
}

/**
* This method initializes Exit
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getExit() {
if (Exit == null) {
Exit = new JMenuItem();
Exit.setText("Exit");
}
return Exit;
}

/**
* This method initializes Impossible
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getImpossible() {
if (Impossible == null) {
Impossible = new JRadioButton();
Impossible.setText("Impossible");
Impossible.addActionListener(this);
}
return Impossible;
}

/**
* This method initializes Hard
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getHard() {
if (Hard == null) {
Hard = new JRadioButton();
Hard.setText("Hard");
Hard.addActionListener(this);
}
return Hard;
}

/**
* This method initializes Medium
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getMedium() {
if (Medium == null) {
Medium = new JRadioButton();
Medium.setText("Medium");
Medium.addActionListener(this);
Medium.setSelected(true);
}
return Medium;
}

/**
* This method initializes Easy
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getEasy() {
if (Easy == null) {
Easy = new JRadioButton();
Easy.setText("Easy");
Easy.addActionListener(this);
}
return Easy;
}

/**
* This method initializes Help
*
* @return javax.swing.JMenu
*/
private JMenu getHelp() {
if (Help == null) {
Help = new JMenu();
Help.setText("Help");
Help.add(getHowToPlay());
Help.add(getAbout());
}
return Help;
}

/**
* This method initializes HowToPlay
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getHowToPlay() {
if (HowToPlay == null) {
HowToPlay = new JMenuItem();
HowToPlay.setText("How To Play");
}
return HowToPlay;
}

/**
* This method initializes About
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getAbout() {
if (About == null) {
About = new JMenuItem();
About.setText("About");
}
return About;
}

/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.weightx = 1.0;
jPanel = new JPanel();
jPanel.setBackground(Color.darkGray);
jPanel.setLayout(new GridBagLayout());
jPanel.add(getJSplitPane(), gridBagConstraints);
}
return jPanel;
}

/**
* This method initializes jSplitPane
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane() {
if (jSplitPane == null) {
jSplitPane = new JSplitPane();
jSplitPane.setBackground(Color.darkGray);
jSplitPane.setForeground(Color.darkGray);
}

jSplitPane.setOneTouchExpandable(false);
jSplitPane.setLeftComponent(getJContentPane2());
jSplitPane.setRightComponent(jPanelGame);
jSplitPane.setDividerSize(0);
jSplitPane.setDividerLocation(155);
return jSplitPane;
}

/**
* This method initializes jContentPane2
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane2() {
if (jContentPane2 == null) {
jLabel = new JLabel();
jLabel.setBackground(Color.darkGray);
jLabel.setForeground(Color.white);
jLabel.setText("You have "+numMovesLeft+" moves left");
jContentPane2 = new JPanel();
jContentPane2.setBackground(Color.darkGray);
jContentPane2.setLayout(new BorderLayout());
jContentPane2.add(getJPanel2(), BorderLayout.SOUTH);
jContentPane2.add(jLabel, BorderLayout.NORTH);
}
return jContentPane2;
}

/**
* This method initializes jPanel2
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel2() {
if (jPanel2 == null) {
GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
gridBagConstraints7.gridx = 0;
gridBagConstraints7.gridy = 1;
GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
gridBagConstraints2.gridx = 3;
gridBagConstraints2.insets = new Insets(7, 0, 7, 0);
gridBagConstraints2.ipadx = 10;
gridBagConstraints2.ipady = 25;
gridBagConstraints2.gridy = 10;
GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
gridBagConstraints5.gridx = 3;
gridBagConstraints5.insets = new Insets(7, 0, 7, 0);
gridBagConstraints5.ipadx = 10;
gridBagConstraints5.ipady = 25;
gridBagConstraints5.anchor = GridBagConstraints.CENTER;
gridBagConstraints5.gridy = 1;
GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
gridBagConstraints4.gridx = 3;
gridBagConstraints4.insets = new Insets(7, 0, 7, 0);
gridBagConstraints4.ipadx = 10;
gridBagConstraints4.ipady = 25;
gridBagConstraints4.gridy = 9;
GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
gridBagConstraints3.gridx = 3;
gridBagConstraints3.insets = new Insets(7, 0, 7, 0);
gridBagConstraints3.ipadx = 10;
gridBagConstraints3.ipady = 25;
gridBagConstraints3.gridy = 8;
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.gridx = 3;
gridBagConstraints1.anchor = GridBagConstraints.CENTER;
gridBagConstraints1.insets = new Insets(7, 0, 7, 0);
gridBagConstraints1.ipadx = 10;
gridBagConstraints1.ipady = 25;
gridBagConstraints1.fill = GridBagConstraints.NONE;
gridBagConstraints1.gridy = 7;
jPanel2 = new JPanel();
jPanel2.setLayout(new GridBagLayout());
jPanel2.setBackground(Color.darkGray);
jPanel2.add(getRedbutton(), gridBagConstraints1);
jPanel2.add(getBluebutton(), gridBagConstraints3);
jPanel2.add(getPurplebutton(), gridBagConstraints4);
jPanel2.add(getYellowbutton(), gridBagConstraints5);
jPanel2.add(getGreenButton(), gridBagConstraints2);
jPanel2.add(getJPanel3(), gridBagConstraints7);
}
return jPanel2;
}

/**
* This method initializes Redbutton
*
* @return javax.swing.JButton
*/
private JButton getRedbutton() {
if (Redbutton == null) {
Redbutton = new JButton();
Redbutton.setBackground(Color.red);
Redbutton.addActionListener(this);

}
return Redbutton;
}

/**
* This method initializes Bluebutton
*
* @return javax.swing.JButton
*/
private JButton getBluebutton() {
if (Bluebutton == null) {
Bluebutton = new JButton();
Bluebutton.setBackground(Color.blue);
Bluebutton.addActionListener(this);
}
return Bluebutton;
}

/**
* This method initializes Purplebutton
*
* @return javax.swing.JButton
*/
private JButton getPurplebutton() {
if (Purplebutton == null) {
Purplebutton = new JButton();
Purplebutton.setBackground(Color.magenta);
Purplebutton.addActionListener(this);
}
return Purplebutton;
}

/**
* This method initializes Yellowbutton
*
* @return javax.swing.JButton
*/
private JButton getYellowbutton() {
if (Yellowbutton == null) {
Yellowbutton = new JButton();
Yellowbutton.setBackground(Color.yellow);
Yellowbutton.addActionListener(this);
}
return Yellowbutton;
}

/**
* This method initializes GreenButton
*
* @return javax.swing.JButton
*/
private JButton getGreenButton() {
if (GreenButton == null) {
GreenButton = new JButton();
GreenButton.setBackground(Color.green);
GreenButton.addActionListener(this);
}
return GreenButton;
}

/**
* This method initializes jPanel3
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel3() {
if (jPanel3 == null) {
jPanel3 = new JPanel();
jPanel3.setBackground(Color.darkGray);
jPanel3.setLayout(new GridBagLayout());
}
return jPanel3;
}

@Override
public void actionPerformed(ActionEvent event)
{
//gets the button that was clicked
Object source = event.getSource();
if(source==Bluebutton)
{
if(colorSelected!=2)
{
numMovesLeft--;
jLabel.setText("You have "+numMovesLeft+" moves left");
jLabel.validate();
colorSelected=2;
draw.setChosen(2);
draw.Sort();
jPanelGame=draw.GetPanel();
jSplitPane.setRightComponent(jPanelGame);
jPanel.validate();
}
}
else if(source==Redbutton)
{
if(colorSelected!=0)
{
numMovesLeft--;
jLabel.setText("You have "+numMovesLeft+" moves left");
jLabel.validate();
colorSelected=0;
draw.setChosen(0);
draw.Sort();
jPanelGame=draw.GetPanel();
jSplitPane.setRightComponent(jPanelGame);
jPanel.validate();
}
}
else if(source==Purplebutton)
{
if(colorSelected!=4)
{
numMovesLeft--;
jLabel.setText("You have "+numMovesLeft+" moves left");
jLabel.validate();
colorSelected=4;
draw.setChosen(4);
draw.Sort();
jPanelGame=draw.GetPanel();
jSplitPane.setRightComponent(jPanelGame);
jPanel.validate();
}

}
else if(source==Yellowbutton)
{
if(colorSelected!=1)
{
numMovesLeft--;
jLabel.setText("You have "+numMovesLeft+" moves left");
jLabel.validate();
colorSelected=1;
draw.setChosen(1);
draw.Sort();
jPanelGame=draw.GetPanel();
jSplitPane.setRightComponent(jPanelGame);
jPanel.validate();
}


}
else if(source==GreenButton)
{
if(colorSelected!=3)
{
numMovesLeft--;
jLabel.setText("You have "+numMovesLeft+" moves left");
jLabel.validate();
colorSelected=3;
draw.setChosen(3);
draw.Sort();
jPanelGame=draw.GetPanel();
jSplitPane.setRightComponent(jPanelGame);
jPanel.validate();
}
}
else if(source==Easy)
{
draw= new Draw(10);
numMovesLeft=25;
jPanelGame=draw.GetPanel();
jSplitPane.setRightComponent(jPanelGame);
jPanel.validate();
}
else if(source==Medium)
{
draw= new Draw(10);
numMovesLeft=20;
jPanelGame=draw.GetPanel();
jSplitPane.setRightComponent(jPanelGame);
jPanel.validate();
}
else if(source==Hard)
{
draw= new Draw(15);
numMovesLeft=20;
jPanelGame=draw.GetPanel();
jSplitPane.setRightComponent(jPanelGame);
jPanel.validate();
}
else if(source==Impossible)
{
draw= new Draw(20);
numMovesLeft=22;
jPanelGame=draw.GetPanel();
jSplitPane.setRightComponent(jPanelGame);
jPanel.validate();

}
}
}
// @jve:decl-index=0:visual-constraint="165,30"

Edited by da tick 07 - 3/23/11 at 6:56pm
Mitx Love
(13 items)
 
  
CPUMotherboardRAMHard Drive
Pentium G6950 Zotac H55 ITX 2x2GB Kingston 500GB Hitachi 
OSPowerMouseMouse Pad
Windows Server 2008 R2 Lite-on 300w Logitech Wireless Laser ULTRA wrist rest 
  hide details  
Reply
Mitx Love
(13 items)
 
  
CPUMotherboardRAMHard Drive
Pentium G6950 Zotac H55 ITX 2x2GB Kingston 500GB Hitachi 
OSPowerMouseMouse Pad
Windows Server 2008 R2 Lite-on 300w Logitech Wireless Laser ULTRA wrist rest 
  hide details  
Reply
post #2 of 9
Its gonna be hard to diagnose the problem without seeing any of your code wink.gif

Maybe your not instaniating the buttons when you create a new GUI?
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-930 D0 3.8Ghz ASUS P6T SE PowerColor HD5870 1GB 6GB Corsair Dominator XMS3 8-8-8-20 1200Mhz 
Hard DriveOSMonitorPower
1TB Wester Digital Windows 7 Home 64bit Acer 23" XFX 850w Black Edtion 
Case
HAF 932 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-930 D0 3.8Ghz ASUS P6T SE PowerColor HD5870 1GB 6GB Corsair Dominator XMS3 8-8-8-20 1200Mhz 
Hard DriveOSMonitorPower
1TB Wester Digital Windows 7 Home 64bit Acer 23" XFX 850w Black Edtion 
Case
HAF 932 
  hide details  
Reply
post #3 of 9
Thread Starter 
Quote:
Originally Posted by CovertCover;12845537 
Its gonna be hard to diagnose the problem without seeing any of your code wink.gif

Maybe your not instaniating the buttons when you create a new GUI?

Ill put the gui in the OP but MANNNN thats a lot of code

basically it calls the initializer which calls the jpanel which in constructed of a grid which adds the buttons into place. when the buttons are called to be added, they are initialized with their color. kind of confusing but I used eclipse visual editor
Edited by da tick 07 - 3/23/11 at 6:57pm
Mitx Love
(13 items)
 
  
CPUMotherboardRAMHard Drive
Pentium G6950 Zotac H55 ITX 2x2GB Kingston 500GB Hitachi 
OSPowerMouseMouse Pad
Windows Server 2008 R2 Lite-on 300w Logitech Wireless Laser ULTRA wrist rest 
  hide details  
Reply
Mitx Love
(13 items)
 
  
CPUMotherboardRAMHard Drive
Pentium G6950 Zotac H55 ITX 2x2GB Kingston 500GB Hitachi 
OSPowerMouseMouse Pad
Windows Server 2008 R2 Lite-on 300w Logitech Wireless Laser ULTRA wrist rest 
  hide details  
Reply
post #4 of 9
Now is it the 4 buttons, RedButton, PurpleButton... Etc
that keep screwing up?
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-930 D0 3.8Ghz ASUS P6T SE PowerColor HD5870 1GB 6GB Corsair Dominator XMS3 8-8-8-20 1200Mhz 
Hard DriveOSMonitorPower
1TB Wester Digital Windows 7 Home 64bit Acer 23" XFX 850w Black Edtion 
Case
HAF 932 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-930 D0 3.8Ghz ASUS P6T SE PowerColor HD5870 1GB 6GB Corsair Dominator XMS3 8-8-8-20 1200Mhz 
Hard DriveOSMonitorPower
1TB Wester Digital Windows 7 Home 64bit Acer 23" XFX 850w Black Edtion 
Case
HAF 932 
  hide details  
Reply
post #5 of 9
Thread Starter 
just the buttons. everything else works perfectly. the size is even hard coded and yet they are created larger than they should be
Mitx Love
(13 items)
 
  
CPUMotherboardRAMHard Drive
Pentium G6950 Zotac H55 ITX 2x2GB Kingston 500GB Hitachi 
OSPowerMouseMouse Pad
Windows Server 2008 R2 Lite-on 300w Logitech Wireless Laser ULTRA wrist rest 
  hide details  
Reply
Mitx Love
(13 items)
 
  
CPUMotherboardRAMHard Drive
Pentium G6950 Zotac H55 ITX 2x2GB Kingston 500GB Hitachi 
OSPowerMouseMouse Pad
Windows Server 2008 R2 Lite-on 300w Logitech Wireless Laser ULTRA wrist rest 
  hide details  
Reply
post #6 of 9
Could it be due to the fact that your
Code:
getXXXButton()

methods only intialize a button if the button is already null? Maybe when your creating the GUI for the second time the button isn't null to start? (I'll have to look over your code more, but thats just a quick guess)
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-930 D0 3.8Ghz ASUS P6T SE PowerColor HD5870 1GB 6GB Corsair Dominator XMS3 8-8-8-20 1200Mhz 
Hard DriveOSMonitorPower
1TB Wester Digital Windows 7 Home 64bit Acer 23" XFX 850w Black Edtion 
Case
HAF 932 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-930 D0 3.8Ghz ASUS P6T SE PowerColor HD5870 1GB 6GB Corsair Dominator XMS3 8-8-8-20 1200Mhz 
Hard DriveOSMonitorPower
1TB Wester Digital Windows 7 Home 64bit Acer 23" XFX 850w Black Edtion 
Case
HAF 932 
  hide details  
Reply
post #7 of 9
Thread Starter 
Quote:
Originally Posted by CovertCover;12846032 
Could it be due to the fact that your
Code:
getXXXButton()

methods only intialize a button if the button is already null? Maybe when your creating the GUI for the second time the button isn't null to start? (I'll have to look over your code more, but thats just a quick guess)

Well, if the button wasn't null, it would still be added to the grid with the correct colors and everything. That is just a catch so it doesn't have to ability to initialize itself more than once.

I'm only created the GUI once anyways. Since the GUI cannot have a main in it by the nature of the code, the Main class ONLY calls the GUI and sets it to be visible.

I might just try to go with PNG's because I mean, they cant change color. The buttons work fine. It is just that the color an position is f'ed up. I'm just teaching myself graphics TBH. My teacher hasn't taught us any graphics. This is just a program to get me comfortable with graphics and then for the final project we will demo this and our own bejeweled game.


Logic
Main > GUI > Draw > Grid
Main: Calls GUI (allows me to turn this into an application)
GUI: Basically all graphics seen
Draw: Creates the "grid"
Grid: Each "box" of the grid with its own properties such as position and color
Edited by da tick 07 - 3/23/11 at 7:43pm
Mitx Love
(13 items)
 
  
CPUMotherboardRAMHard Drive
Pentium G6950 Zotac H55 ITX 2x2GB Kingston 500GB Hitachi 
OSPowerMouseMouse Pad
Windows Server 2008 R2 Lite-on 300w Logitech Wireless Laser ULTRA wrist rest 
  hide details  
Reply
Mitx Love
(13 items)
 
  
CPUMotherboardRAMHard Drive
Pentium G6950 Zotac H55 ITX 2x2GB Kingston 500GB Hitachi 
OSPowerMouseMouse Pad
Windows Server 2008 R2 Lite-on 300w Logitech Wireless Laser ULTRA wrist rest 
  hide details  
Reply
post #8 of 9
Yeah, I Didnt see that. Its hard to see how the code flows on a phone. Anyway, Ill take another look at it tomorrow when I have access to a computer, and see if I can pinpoint the error.
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-930 D0 3.8Ghz ASUS P6T SE PowerColor HD5870 1GB 6GB Corsair Dominator XMS3 8-8-8-20 1200Mhz 
Hard DriveOSMonitorPower
1TB Wester Digital Windows 7 Home 64bit Acer 23" XFX 850w Black Edtion 
Case
HAF 932 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-930 D0 3.8Ghz ASUS P6T SE PowerColor HD5870 1GB 6GB Corsair Dominator XMS3 8-8-8-20 1200Mhz 
Hard DriveOSMonitorPower
1TB Wester Digital Windows 7 Home 64bit Acer 23" XFX 850w Black Edtion 
Case
HAF 932 
  hide details  
Reply
post #9 of 9
Well, actually the drawComponent method is invoked on all instances on the contentPane of the jFrame each if the resize method is invoked by an event. I am not going to read the code through, but how do you handle resizing? The best thing to do here would be to directly sublcass JButton and specify a color parameter in the initialization of your 'GameButton', which automatically initializes itself with a given size/color.


Debug it, take a step back, incrementally develop, see what it is that you added that caused this strange behavior. If I have free time, I will pull it down and take a look, I am currently rather busy sadly.
For sale
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-920 Asus P6T Deluxe Asus GTX460 TOP 768mb G Skill ECO 1600 CAS7 1.35V 
Hard DriveOptical DriveOSMonitor
2x Vertex 60 GB raid[0] Asus DVDRW W7,Ubuntu 2 xAsus VH236H 
KeyboardPowerCaseMouse Pad
Razer Ultra X3 1000W HAF 932 My Desk 
  hide details  
Reply
For sale
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-920 Asus P6T Deluxe Asus GTX460 TOP 768mb G Skill ECO 1600 CAS7 1.35V 
Hard DriveOptical DriveOSMonitor
2x Vertex 60 GB raid[0] Asus DVDRW W7,Ubuntu 2 xAsus VH236H 
KeyboardPowerCaseMouse Pad
Razer Ultra X3 1000W HAF 932 My Desk 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming