本文整理汇总了Java中java.awt.Label.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java Label.setBackground方法的具体用法?Java Label.setBackground怎么用?Java Label.setBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Label
的用法示例。
在下文中一共展示了Label.setBackground方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setColor
import java.awt.Label; //导入方法依赖的package包/类
public void setColor(Label l,int value)
{
l.setText(value+"");
l.setFont(new java.awt.Font("Arial", 1, 60));
if(value==0)
{
l.setText("");
l.setBackground(Color.white);
}
else if(value==2)
l.setBackground(Color.yellow);
else if(value==4)
l.setBackground(Color.orange);
else if(value==8)
l.setBackground(Color.cyan);
else if(value==16)
l.setBackground(Color.green);
else if(value==32)
l.setBackground(Color.pink);
else if(value==64)
l.setBackground(Color.red);
else if(value==128)
l.setBackground(Color.blue);
else if(value==256)
l.setBackground(Color.magenta);
else if(value==512)
l.setBackground(Color.lightGray);
else if(value==1024)
l.setBackground(Color.darkGray);
else if(value==2048)
l.setBackground(Color.black);
if(value>64)
l.setFont(new java.awt.Font("Arial", 1, 45));
if(value>512)
l.setFont(new java.awt.Font("Arial", 1, 30));
}
示例2: initGUI
import java.awt.Label; //导入方法依赖的package包/类
/**
* Create the graphical user interface. This is AWT code.
*/
private void initGUI() {
// all panels
Panel pQuery = new Panel();
Panel pCommand = new Panel();
Panel pButton = new Panel();
Panel pRecent = new Panel();
Panel pResult = new Panel();
Panel pBorderWest = new Panel();
Panel pBorderEast = new Panel();
Panel pBorderSouth = new Panel();
pQuery.setLayout(new BorderLayout());
pCommand.setLayout(new BorderLayout());
pButton.setLayout(new BorderLayout());
pRecent.setLayout(new BorderLayout());
pResult.setLayout(new BorderLayout());
pBorderWest.setBackground(SystemColor.control);
pBorderSouth.setBackground(SystemColor.control);
pBorderEast.setBackground(SystemColor.control);
// labels
Label lblCommand = new Label(" Command", Label.LEFT);
Label lblRecent = new Label(" Recent", Label.LEFT);
Label lblResult = new Label(" Result", Label.LEFT);
lblCommand.setBackground(SystemColor.control);
lblRecent.setBackground(SystemColor.control);
lblResult.setBackground(SystemColor.control);
// buttons
butExecute = new Button("Execute");
butScript = new Button("Script");
butImport = new Button("Import");
pButton.add("South", butScript);
pButton.add("Center", butExecute);
pButton.add("North", butImport);
// command - textarea
Font fFont = new Font("Dialog", Font.PLAIN, 12);
txtCommand = new TextArea(5, 40);
txtCommand.setFont(fFont);
// recent - choice
choRecent = new Choice();
// result - grid
gResult = new Grid();
// combine it
setLayout(new BorderLayout());
pRecent.add("Center", choRecent);
pRecent.add("North", lblRecent);
pCommand.add("North", lblCommand);
pCommand.add("East", pButton);
pCommand.add("Center", txtCommand);
pCommand.add("South", pRecent);
pResult.add("North", lblResult);
pResult.add("Center", gResult);
pQuery.add("North", pCommand);
pQuery.add("Center", pResult);
add("Center", pQuery);
add("West", pBorderWest);
add("East", pBorderEast);
add("South", pBorderSouth);
// [email protected] 20011210 - patch 450412 by [email protected]
doLayout();
}
示例3: createLabel
import java.awt.Label; //导入方法依赖的package包/类
protected static Label createLabel(String s) {
Label l = new Label(s);
l.setBackground(SystemColor.control);
return l;
}
示例4: createLabel
import java.awt.Label; //导入方法依赖的package包/类
/**
* Method declaration
*
*
* @param s
*/
private Label createLabel(String s) {
Label l = new Label(s);
l.setBackground(SystemColor.control);
return l;
}
示例5: createLabel
import java.awt.Label; //导入方法依赖的package包/类
/**
* Method declaration
*
*
* @param s
*
* @return
*/
protected static Label createLabel(String s) {
Label l = new Label(s);
l.setBackground(SystemColor.control);
return l;
}
示例6: createLabel
import java.awt.Label; //导入方法依赖的package包/类
/**
* Method declaration
*
*
* @param s
*
* @return
*/
private Label createLabel(String s) {
Label l = new Label(s);
l.setBackground(SystemColor.control);
return l;
}