⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scrolldemo.java

📁 java swing 开发代码
💻 JAVA
字号:
// ScrollDemo.java// A simple JScrollPane demonstration.//package	jswing.ch11;import javax.swing.*;import java.awt.*;public class ScrollDemo extends JFrame {  JScrollPane scrollpane;  public ScrollDemo() {    super("JScrollPane Demonstration");    setSize(300, 200);    setDefaultCloseOperation(EXIT_ON_CLOSE);    init();    setVisible(true);  }  public void init() {    JRadioButton form[][] = new JRadioButton[12][5];    String counts[] = { "", "0-1", "2-5", "6-10", "11-100", "101+" };    String categories[] = { "Household", "Office", "Extended Family",                            "Company (US)", "Company (World)", "Team",                            "Will", "Birthday Card List", "High School",                            "Country", "Continent", "Planet" };    JPanel p = new JPanel();    p.setSize(600, 400);    p.setLayout(new GridLayout(13, 6, 10, 0));    for (int row = 0; row < 13; row++) {      ButtonGroup bg = new ButtonGroup();      for (int col = 0; col < 6; col++) {        if (row == 0) {          p.add(new JLabel(counts[col]));        }        else {          if (col == 0) {            p.add(new JLabel(categories[row - 1]));          }          else {            form[row - 1][col - 1] = new JRadioButton();            bg.add(form[row -1][col - 1]);            p.add(form[row -1][col - 1]);         }        }      }    }    scrollpane = new JScrollPane(p);    getContentPane().add(scrollpane, BorderLayout.CENTER);  }  public static void main(String args[]) {    new ScrollDemo();  }}

⌨️ 快捷键说明

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