抄别人的例子,学习基础

 

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/***
 * 2011-AUG-24
 * @author houwen
 *
 */
public class View {
    private int row ;
    private int rows;
    private int pages;
    private JFrame window = new JFrame("@DB:192.168.0.20:tarena:sd0704_TomLin records");
    private JTextArea output = new JTextArea(20,50);
    private JScrollPane jsp = new JScrollPane(output);
    private JTextField jpage = new JTextField(2);
    private JLabel jl1 = new JLabel("第");
    private JLabel jl2 = new JLabel("页");
    private JButton jb1 = new JButton("goto");
    private JButton jb2 = new JButton("选择每页显示行数");
    private JButton jb3 = new JButton("上一页");
    private JButton jb4 = new JButton("下一页");
    private JButton jb5 = new JButton("退出");
    private JPanel jp1 = new JPanel(new FlowLayout());
    private JPanel jp2 = new JPanel(new FlowLayout());
    private JPanel jp3 = new JPanel(new FlowLayout());
   
    class ActionLis implements ActionListener{

        public void actionPerformed(ActionEvent e) {
            if(e.getSource()==jb1){
                int page = Integer.parseInt(jpage.getText());
               
            }else if(e.getSource()==jb2){
                int row = Integer.parseInt(
                        JOptionPane.showInputDialog(window, "请输入行数:"));
               
            }else if(e.getSource()==jb3){
                pages--;
            }else if(e.getSource()==jb4){
                output.setText(pages+++"");
            }else if(e.getSource()==jb5){
                System.exit(0);
            }
        }
       
    }
   
    public View(){
        window.setLayout(new FlowLayout());
       
        jp1.add(jsp);
        jp2.add(jb2);
        jp2.add(jl1);
        jp2.add(jpage);
        jp2.add(jl2);
        jp2.add(jb1);
        jp3.add(jb3);
        jp3.add(jb4);
        jp3.add(jb5);
       
        ActionLis listener = new ActionLis();
        jb1.addActionListener(listener);
        jb2.addActionListener(listener);
        jb3.addActionListener(listener);
        jb4.addActionListener(listener);
        jb5.addActionListener(listener);
       
        window.add(jp1);
        window.add(jp2);
        window.add(jp3);
       
        window.setSize(600,500);
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setVisible(true);
       
    }
   
    public static void main(String[] args){
        new View();
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值