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

📄 printdialog.java

📁 Java程序设计技巧与开发实例附书源代码。
💻 JAVA
字号:
import java.awt.GridLayout;import java.awt.FlowLayout;import java.awt.BorderLayout;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;public class PrintDialog extends JFrame implements ActionListener{  private JButton okay = new JButton("OK");   private JButton cancel = new JButton("Cancel");   private JRadioButton all = new JRadioButton("All Pages");   private JRadioButton current = new JRadioButton("Current Page");   private JRadioButton selected = new JRadioButton("Selected Pages");   private JCheckBox numbers = new JCheckBox("Include Line Numbers");   private JCheckBox headers = new JCheckBox("Header on all pages");   private JCheckBox fileName = new JCheckBox("File name on each page");   public PrintDialog()   {  super("Print Dialog");      ButtonGroup pageOptions = new ButtonGroup();      pageOptions.add(all);      pageOptions.add(current);      pageOptions.add(selected);      all.setSelected(true);      JPanel pagePanel = new JPanel(new GridLayout(3,1));      pagePanel.add(all);          all.addActionListener(this);      pagePanel.add(current);      current.addActionListener(this);      pagePanel.add(selected);     selected.addActionListener(this);      pagePanel.setBorder(new TitledBorder("Print Range:"));      JPanel optionsPanel = new JPanel(new GridLayout(3,1));      optionsPanel.add(numbers);   numbers.addActionListener(this);      optionsPanel.add(headers);   headers.addActionListener(this);      optionsPanel.add(fileName);  fileName.addActionListener(this);      optionsPanel.setBorder(new TitledBorder("Format Options:"));      JPanel buttons = new JPanel(new FlowLayout());      buttons.add(okay);           okay.addActionListener(this);      buttons.add(cancel);         cancel.addActionListener(this);      getContentPane().setLayout(new BorderLayout());      getContentPane().add("West", pagePanel);      getContentPane().add("East", optionsPanel);      getContentPane().add("South", buttons);      validate(); pack(); setVisible(true);   }   public void actionPerformed(ActionEvent ae)   {  if ((ae.getSource() == okay) || (ae.getSource() == cancel))         System.exit(0);      else         System.out.println("Command: " + ae.getActionCommand());   }   public static void main(String args[])   {  try      {  String lf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";         UIManager.setLookAndFeel(lf);      }      catch (Exception e)      {  System.err.println("Exception: " + e); }      PrintDialog pd = new PrintDialog();   }}

⌨️ 快捷键说明

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