Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » why cannot change foreground color?(java foregroundcolor)
why cannot change foreground color? [message #1088627] Sat, 17 August 2013 11:07 Go to next message
J kids is currently offline J kidsFriend
Messages: 1
Registered: August 2013
Junior Member
package q2sept2011;
import javax.swing.*;
import java.awt.*;
import java.awt.Color.*;
import java.awt.Font.*;


public class Q2sept2011 extends JFrame{




public static void main(String[] args) {
Q2sept2011 frame = new Q2sept2011();
frame.setSize(300,125);
frame.setTitle("Changging the front style");
frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);



// TODO code application logic here
}
public Q2sept2011(){
String[]font ={"Times Roman","Verdana","Courier"};

String[]size ={"15","20","25"};

JComboBox c1=new JComboBox(font);
JComboBox c2=new JComboBox(size);
JPanel p1= new JPanel();
setLayout(new BorderLayout());
p1.setLayout(new GridLayout(1,3));
add(p1,BorderLayout.NORTH);
p1.add(new JLabel("Font Name"));
p1.add(new JComboBox(font));
p1.add(new JLabel("Font Size"));
p1.add(new JComboBox(size));


JPanel p2= new JPanel();



add(p2,BorderLayout.CENTER);
p2.add(new JLabel("Good!"));
p2.setBackground(Color.RED);
p2.setForeground(Color.blue);
/*the "good" still in black.while running the program.*/




}
}
Re: why cannot change foreground color? [message #1090256 is a reply to message #1088627] Mon, 19 August 2013 23:03 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4434
Registered: July 2009
Senior Member

This question doesn't actually have anything to do with Eclipse. You'll reach a wider, and more appropriate, audience at another site like http://www.coderanch.com/forums.

_
Nitin Dahyabhai
Eclipse Web Tools Platform

[Updated on: Mon, 19 August 2013 23:03]

Report message to a moderator

Previous Topic:kernel error occur
Next Topic:closing perspective
Goto Forum:
  


Current Time: Fri Apr 19 23:15:52 GMT 2024

Powered by FUDForum. Page generated in 0.05282 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top