字體大小及顏色
創(chuàng)新互聯(lián)專(zhuān)業(yè)為企業(yè)提供雷山網(wǎng)站建設(shè)、雷山做網(wǎng)站、雷山網(wǎng)站設(shè)計(jì)、雷山網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、雷山企業(yè)網(wǎng)站模板建站服務(wù),十年雷山做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
a:Java代碼區(qū)域的字體大小和顏色:
window -- Preferences -- General -- Appearance -- Colors And Fonts -- Java修改 -- Java Edit Text Font
b:控制臺(tái)
window -- Preferences -- General -- Appearance -- Colors And Fonts -- Debug -- Console font
c:其他文件
window -- Preferences -- General -- Appearance -- Colors And Fonts -- Basic -- Text Font
**************************************************************
新建一個(gè)類(lèi)ChangeColor.java,代碼如下:
**************************************************************
import?java.awt.Color;
import?java.awt.event.MouseEvent;
import?java.awt.event.MouseMotionListener;
import?javax.swing.JFrame;
/**
*?@author?Godwin
*?@version?2010-05-16
*/
public?class?ChangeColor?extends?JFrame?implements?MouseMotionListener?{
public?ChangeColor()?{
this.setTitle("Change?Color");
this.setBounds(300,?200,?400,?300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.getContentPane().setBackground(Color.GREEN);
this.addMouseMotionListener(this);
}
public?void?mouseMoved(MouseEvent?e)?{
if?(e.getX()??(this.getWidth()?/?2))?{
this.getContentPane().setBackground(Color.RED);
}?else?{
this.getContentPane().setBackground(Color.BLUE);
}
}
public?void?mouseDragged(MouseEvent?e)?{
}
public?static?void?main(String[]?args)?{
new?ChangeColor();
}
}
**************************************************************
運(yùn)行結(jié)果如下:
**************************************************************
按照你的要求,編寫(xiě)的Java程序如下
import?java.awt.Color;
import?java.awt.Graphics;
import?javax.swing.JFrame;
public?class?F?extends?JFrame?implements?Runnable{
Color[]?colors?=?{Color.red,Color.orange,Color.yellow,Color.green,Color.cyan,Color.blue,Color.magenta,Color.black};??
int?i=0;
F(){
setTitle("變色正方形");
setSize(400,?400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
}
public?void?paint(Graphics?g){
g.setColor(colors[i]);
g.drawRect(100,100,200,200);
}
@Override
public?void?run()?{
while(true){
try?{
Thread.sleep(1000);
}?catch?(InterruptedException?e)?{
e.printStackTrace();
}
if(i7)
i++;
else
i=0;
repaint();
}
}
public?static?void?main(String[]?args)?{
F?f=new?F();
Thread?t=new?Thread(f);
t.start();
}
}
運(yùn)行結(jié)果