Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » JAVA programming problem encountered! (for Mac)(Button's Background Color does not change)
JAVA programming problem encountered! (for Mac) [message #1061287] Thu, 30 May 2013 22:44
sean19831006 fu is currently offline sean19831006 fu
Messages: 1
Registered: May 2013
Junior Member
Smile While i was programming java on Mac OS 10.7 Lion, i found it negative to change the Button's Background Color via compiling

However it turned out positive on Whindows 7 64-bit, with the Same Program Code!


Is it the problem with the operationg system, or the program itself?
I wonder if there is helf from you guys!!!

Thx!!!!!!!!! Razz


Here is the code:


import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class Exercise12_10_1 extends JFrame
{
public Exercise12_10_1()
{
setLayout(new GridLayout(8, 8, 0, 0));

for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
JButton butt = new JButton();

if ((i + j) % 2 == 0)
{
butt.setBackground(Color.RED);
System.out.println("1");
} else
{
butt.setBackground(Color.GREEN);
System.out.println("2");
}

add(butt);
}
}
}

public static void main(String[] args)
{
Exercise12_10_1 frame = new Exercise12_10_1();
frame.setTitle("Exercise12_10_1");
frame.setSize(400, 400);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Previous Topic:Issue with hover of folding
Next Topic:eclipse shortcuts
Goto Forum:
  


Current Time: Thu Aug 21 00:39:36 EDT 2014

Powered by FUDForum. Page generated in 0.01476 seconds