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

📄 uifreesell.java

📁 this is asimple java code to play with event free sill
💻 JAVA
字号:
// File  : freesell/UIFreeSell.java// Description: Freecell solitaire program.//         Main program / JFrame.  Adds a few components and the //         main graphics area, UICardPanel, that handles the mouse and painting.// Author: Fred Swartz - Feb 20 2007 - Placed in public domain.package freecell;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;/////////////////////////////////////////////////////////////// class UIFreeSellpublic class UIFreeSell extends JFrame {    //=================================================================== fields    private GameModel _model = new GameModel();        private UICardPanel _boardDisplay;        private JCheckBox _autoCompleteCB = new JCheckBox("Auto Complete");        //===================================================================== main    public static void main(String[] args) {        //... Do all GUI initialization on EDT thread.  This is the        //    correct way, but is often omitted because the other        //    almost always(!) works.        SwingUtilities.invokeLater(new Runnable() {            public void run() {                new UIFreeSell();            }        });    }        //============================================================== constructor    public UIFreeSell() {        _boardDisplay = new UICardPanel(_model);                //... Create button and check box.        JButton newGameBtn = new JButton("New Game");        newGameBtn.addActionListener(new ActionNewGame());                _autoCompleteCB.setSelected(true);        _autoCompleteCB.addActionListener(new ActionAutoComplete());        _boardDisplay.setAutoCompletion(_autoCompleteCB.isSelected());                //... Do layout        JPanel controlPanel = new JPanel(new FlowLayout());        controlPanel.add(newGameBtn);        controlPanel.add(_autoCompleteCB);                //... Create content pane with graphics area in center (so it expands)        JPanel content = new JPanel();        content.setLayout(new BorderLayout());        content.add(controlPanel, BorderLayout.NORTH);        content.add(_boardDisplay, BorderLayout.CENTER);                //... Set this window's characteristics.        setContentPane(content);        setTitle("Free Cell");        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        pack();        setLocationRelativeTo(null);        setResizable(false);        setVisible(true);    }        ////////////////////////////////////////////////////////////// ActionNewGame    class ActionNewGame implements ActionListener {        public void actionPerformed(ActionEvent evt) {            _model.reset();        }    }        ///////////////////////////////////////////////////////// ActionAutoComplete    class ActionAutoComplete implements ActionListener {        public void actionPerformed(ActionEvent evt) {            _boardDisplay.setAutoCompletion(_autoCompleteCB.isSelected());        }    }    }

⌨️ 快捷键说明

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