public class PokerFrame extends JFrame implements ActionListener{private Dialogs dlg=new Dialogs(null);private Dialogs1 dlg1=new Dialogs1(null);private Dialogs2 dlg2=new Dialogs2(null);private JMenuItem openMI, exitMI, helpMI;private JButton b1=new JButton("洗 牌");private JButton b2=new JButton("发 牌");private JButton b3=new JButton("猜大");private JButton b4=new JButton("猜小");private JMenuBar mbar =new JMenuBar();private JMenu fileMenu =new JMenu("菜单");private JMenu fileMenu1 =new JMenu("关于");public PokerFrame(){Panel pan= new Panel();pan.add(b1);pan.add(b2);pan.add(b3);pan.add(b4);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);JTextField tf=new JTextField(4);Font font =new Font("Monospaced",Font.PLAIN,15);tf.setFont(font);JLabel lb= new JLabel("分 数:");pan.add(lb);lb.setFont(font);pan.add(tf,"North");add(pan,"East");openMI=new JMenuItem("开始");openMI.addActionListener(this);fileMenu.add(openMI);exitMI=new JMenuItem("退出");exitMI.addActionListener(this);fileMenu.add(exitMI);helpMI=new JMenuItem("帮助");helpMI.addActionListener(this);fileMenu1.add(helpMI);mbar.add(fileMenu);mbar.add(fileMenu1);setJMenuBar(mbar);setSize(1024,730);setTitle("天朝纸牌");setBackground(new Color(16,146,60));addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});setVisible(true);}public void actionPerformed(ActionEvent e){if(e.getSource()==exitMI)System.exit(0);if(e.getSource()==openMI)System.out.println("open menu item");if(e.getSource()==helpMI)dlg.setVisible(true);//显示对话框if(e.getSource()==b1)dlg1.setVisible(true);if(e.getSource()==b2)dlg2.setVisible(true);repaint();}public void paint (Graphics g){g.setColor(Color.red);g.drawRect(37,552, 120,144);g.drawRect(36,551, 122,146);}public static void main(String[] args){new PokerFrame();}}
添加回答
举报
0/150
提交
取消