tryapplet.java

来自「非常好的java事例以及带源码事例的java2教程」· Java 代码 · 共 29 行

JAVA
29
字号
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;                             // For the border classes

public class TryApplet extends JApplet 
{
  public void init()
  {
    Container content = getContentPane();                // Get content pane
    content.setLayout(new FlowLayout(FlowLayout.RIGHT)); // Set layout

    JButton button;                                      // Stores a button

    Font[] fonts = { new Font("Arial", Font.ITALIC, 10), // Two fonts
                     new Font("Playbill", Font.PLAIN, 14)
                   };

    BevelBorder edge = new BevelBorder(BevelBorder.RAISED); // Bevelled border

    // Add the buttons using alternate fonts
    for(int i = 1; i <= 6; i++)
    {
      content.add(button = new JButton("Press " + i));  // Add the button
      button.setFont(fonts[i%2]);                // One of our own fonts
      button.setBorder(edge);                    // Set the button border
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?