本文整理匯總了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;
}