本文整理匯總了Java中java.awt.Label.setFont方法的典型用法代碼示例。如果您正苦於以下問題:Java Label.setFont方法的具體用法?Java Label.setFont怎麽用?Java Label.setFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Label
的用法示例。
在下文中一共展示了Label.setFont方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import java.awt.Label; //導入方法依賴的package包/類
@Override
public void init() {
this.setVisible(true);
this.setSize(500, 500);
this.setBackground(Color.green);
this.setLayout(new FlowLayout());
l1 = new Label("User Name");
l2 = new Label("Password");
tf1 = new TextField(20);
tf2 = new TextField(20);
tf2.setEchoChar('*');
b = new Button("Login");
b.addActionListener(this);
Font font = new Font("arial", Font.BOLD, 25);
l1.setFont(font);
l2.setFont(font);
tf1.setFont(font);
tf2.setFont(font);
b.setFont(font);
this.add(l1);
this.add(tf1);
this.add(l2);
this.add(tf2);
this.add(b);
}
示例2: 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));
}
示例3: ConsolePanel
import java.awt.Label; //導入方法依賴的package包/類
/**
* Create a new panel to display the console output
*
* @param e The exception causing the console to be displayed
*/
public ConsolePanel(Exception e) {
setLayout(new BorderLayout());
setBackground(Color.black);
setForeground(Color.white);
Font consoleFont = new Font("Arial", Font.BOLD, 14);
Label slickLabel = new Label("SLICK CONSOLE", Label.CENTER);
slickLabel.setFont(consoleFont);
add(slickLabel, BorderLayout.PAGE_START);
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
textArea.setText(sw.toString());
textArea.setEditable(false);
add(textArea, BorderLayout.CENTER);
// add a border on both sides of the console
add(new Panel(), BorderLayout.LINE_START);
add(new Panel(), BorderLayout.LINE_END);
Panel bottomPanel = new Panel();
bottomPanel.setLayout(new GridLayout(0, 1));
Label infoLabel1 = new Label("An error occured while running the applet.", Label.CENTER);
Label infoLabel2 = new Label("Plese contact support to resolve this issue.", Label.CENTER);
infoLabel1.setFont(consoleFont);
infoLabel2.setFont(consoleFont);
bottomPanel.add(infoLabel1);
bottomPanel.add(infoLabel2);
add(bottomPanel, BorderLayout.PAGE_END);
}
示例4: GHello
import java.awt.Label; //導入方法依賴的package包/類
GHello() {
Label label = new Label("Hello");
label.setFont(new Font("Monospaced", Font.PLAIN, 144));
add(label);
pack();
}
示例5: MainFrame
import java.awt.Label; //導入方法依賴的package包/類
public MainFrame() {
this.setTitle(FRAME_TITLE);
this.setResizable(false);
this.setLayout(null);
Dimension windowSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setBounds((windowSize.width - WIDTH) / 2, (windowSize.height - HEIGHT) / 2, WIDTH, HEIGHT);
Label problemIDLabel = new Label(PROBLEM_ID_LABEL);
problemIDLabel.setBounds(20, 50, 95, 20);
problemIDLabel.setFont(new Font(null, Font.PLAIN, 18));
this.add(problemIDLabel);
problemIDTextField = new TextField();
problemIDTextField.setBounds(130, 50, 145, 20);
this.add(problemIDTextField);
Label bojIDLabel = new Label(BOJ_ID_LABEL);
bojIDLabel.setBounds(20, 100, 95, 20);
bojIDLabel.setFont(new Font(null, Font.PLAIN, 18));
this.add(bojIDLabel);
bojIDTextField = new TextField(User.BOJ_ID);
bojIDTextField.setBounds(130, 100, 145, 20);
this.add(bojIDTextField);
Label bojPasswordLabel = new Label(BOJ_PW_LABEL);
bojPasswordLabel.setBounds(20, 150, 95, 20);
bojPasswordLabel.setFont(new Font(null, Font.PLAIN, 18));
this.add(bojPasswordLabel);
bojPasswordTextField = new TextField(User.BOJ_PASSWORD);
bojPasswordTextField.setEchoChar('*');
bojPasswordTextField.setBounds(130, 150, 145, 20);
this.add(bojPasswordTextField);
submitButton = new Button(SUBMIT_BUTTON);
submitButton.setBounds(75, 200, 150, 40);
submitButton.addActionListener(new SubmitButtonActionListener(this));
this.add(submitButton);
this.addWindowListener(new MainWindowListener());
this.setVisible(true);
}