Java代码颜色配置 Java设置颜色

JAVA中怎么改变字体颜色?

字体大小及颜色

公司主营业务:网站建设、成都网站设计、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出渑池免费做网站回馈大家。

a:Java代码区域的字体大小和颜色:

window -- Preferences -- General -- Appearance -- Colors And Fonts -- Java修改 -- Java Edit Text Font

b:控制台

window -- Preferences -- General -- Appearance -- Colors And Fonts -- Debug -- Console font

c:其他文件

window -- Preferences -- General -- Appearance -- Colors And Fonts -- Basic -- Text Font

java 设置字体颜色

Font类...

在文本组件中 设置...

在JTextComponent中 有设置字体颜色等方法..

java中怎么设置label的字体大小及颜色显示

Java设置label字体代码如下:

ublic class SetColor extends JFrame{

JLabel jlabel = new JLabel("颜色,大小");

public SetColor(){

this.setLayout(null);

jlabel.setBounds(0, 0, 200, 40);

jlabel.setFont(new Font("",1,30));//设置字体大小

jlabel.setForeground(Color.BLUE);//设置字体颜色

this.add(jlabel);

this.setSize(200,200);

this.setVisible(true);

}

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

SetColor sc = new SetColor();

}}

java窗口背景颜色怎么设定?用setBackground()好像不行,请大侠指教!

你好!

首先,你说的Java窗口是指JFrame或者Frame

其次,你说的窗口背景颜色是指直接调用JFrame或者Frame的setBackground(Color color)方法设置后显示出来的颜色。其实,你的想法是正确的,但是我想提醒你的是,你没搞明白JFrame的显示机制。在你直接调用这个方法后,你的确设置了背景颜色,而你看到的却不是直接的JFrame或者Frame,而是JFrame.getContentPane().而JFrame上的contentPane默认是Color.WHITE的,所以,无论你对JFrame或者Frame怎么设置背景颜色,你看到的都只是contentPane.

最后,讲解决办法:

办法A:在完成初始化,调用getContentPane()方法得到一个contentPane容器,然后将其设置为不可见,即setVisible(false)。这样,你就可以看到JFrame的庐山真面貌啦!

核心代码this.getContentPane().setVisible(false);//得到contentPane容器,设置为不可见

实例完整代码如下:

/*

* TestJFrameBGColor.java

*

* Created on 2011-5-8, 0:21:20

*/

package testjframebgcolor;

import java.awt.Color;

/**

*

* @author 叶科良

*/

public class TestJFrameBGColor extends javax.swing.JFrame {

/** Creates new form TestJFrameBGColor */

public TestJFrameBGColor() {

initComponents();

this.getContentPane().setVisible(false);//得到contentPane容器,设置为不可见

}

/** This method is called from within the constructor to

* initialize the form.

* WARNING: Do NOT modify this code. The content of this method is

* always regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// editor-fold defaultstate="collapsed" desc="Generated Code"

private void initComponents() {

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(testjframebgcolor.TestJFrameBGColorApp.class).getContext().getResourceMap(TestJFrameBGColor.class);

setBackground(resourceMap.getColor("Form.background")); // NOI18N

setName("Form"); // NOI18N

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGap(0, 400, Short.MAX_VALUE)

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGap(0, 300, Short.MAX_VALUE)

);

pack();

}// /editor-fold

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new TestJFrameBGColor().setVisible(true);

}

});

}

// Variables declaration - do not modify

// End of variables declaration

}

方法B:将contentPane的颜色设置为你想要的颜色,而不是对JFrame本身设置,

核心代码:this.getContentPane().setBackground(Color.red);//设置contentPane为红色

将核心代码替换方法A核心代码即可实现

方法C:为JFrame添加一个Panel或者JLabel等其他组件,设置其颜色为你想要的颜色,然后将其覆盖JFrame窗口即可

java中如何设置按钮文字的大小、颜色和字体?

submit=newJButton("登陆");\x0d\x0a\x0d\x0asubmit.setFont(newFont("宋体",Font.PLAIN,16));\x0d\x0a三个参数分别表示:字体,样式(粗体,斜体等),字号\x0d\x0a\x0d\x0asubmit.setForeground(Color.RED);\x0d\x0a这个表示给组件上的文字设置颜色Color.RED表示红色\x0d\x0a当然你也可以自己给RGB的值比如submit.setForeground(newColor(215,215,200));\x0d\x0a\x0d\x0aJLabel组件支持HTML标记代码\x0d\x0ainfoLab=newJLabel("用户登陆系统",JLabel.CENTER);\x0d\x0a\x0d\x0a*注意:地址要单引号引起来。这个表示给用户登录系统几个字增加超链接\x0d\x0ainfoLab.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));\x0d\x0a\x0d\x0a这个表示给这个文字添加鼠标样式,当鼠标移动到文字上,鼠标变成手型

求大侠帮忙给这段JAVA代码 设置个背景颜色!

仔细看你的构造,是在一个框架中添加一个总的面板pan,再在pan上添加了6个面板pan1----pan6,所以最上面一层就是这6个面板,要想改变背景色,就改变这6个面板的背景色就可以了,如改变第一个面板的背景色为红色,用语句pan1.setBackground(Color.red);以此类推即可。

注:是写到你的public Inquest()方法里面哈。


当前标题:Java代码颜色配置 Java设置颜色
链接地址:http://myzitong.com/article/hhoipj.html