java实现数独游戏(九宫格)

  • e8_812615
    了解作者
  • 84KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-11 04:20
    上传日期
用java实现的数独游戏,无论界面还是算法,都挺不错
soduku.zip
  • MUSoSu-0.9.6-src
  • sudoku
  • Sudoku.java
    7.5KB
  • SudokuListener.java
    1.1KB
  • SudokuEvent.java
    1.2KB
  • Cell.java
    2KB
  • Board.java
    5.1KB
  • Convert.java
    3.3KB
  • musUI
  • MStatusPanel.java
    3.9KB
  • Settings.java
    10.3KB
  • AboutDialog.java
    3.4KB
  • GetStrDialog.java
    1.9KB
  • Mui.java
    25.8KB
  • ColorDialog.java
    2KB
  • preferencesDialog.java
    6.5KB
  • MSquare.java
    2.7KB
  • ImagePanel.java
    1.1KB
  • GamePanel.java
    17KB
  • ColorSelectPanel.java
    1.9KB
  • GameAction.java
    1KB
  • MSolvePanel.java
    6.5KB
  • PrintUtilities.java
    3.7KB
  • MTimer.java
    2.3KB
  • ExtensionFileFilter.java
    1.4KB
  • GenerateDialog.java
    3.4KB
  • sudokuGenerator
  • GenerateMethod.java
    1.5KB
  • FillFirst.java
    2.7KB
  • sudokuSolver
  • Solver.java
    5.4KB
  • EliminationB.java
    1.2KB
  • CantBeElsewhere.java
    1.6KB
  • HiddenPairs.java
    4.1KB
  • BFTMap.java
    1.9KB
  • DepthFirst.java
    2.1KB
  • EliminationA.java
    3.5KB
  • SolveMethod.java
    3.2KB
  • SolvedSquare.java
    1.3KB
  • PairAnalysis.java
    3.9KB
  • DominoElimination.java
    5.1KB
  • SolveAction.java
    1.2KB
  • musosu_logo.gif
    3.4KB
  • COPYING
    34.3KB
  • default.xml
    1KB
  • musosu.png
    8.4KB
  • Main.java
    1.2KB
  • TODO
    405B
  • README
    454B
  • ChangeLog
    422B
内容介绍
/* * This file is part of MUSoSu. * * MUSoSu is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * MUSoSu is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MUSoSu. If not, see <http://www.gnu.org/licenses/>. */ package musUI; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Image; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowEvent; import java.io.File; import java.io.InputStream; import java.util.Vector; import javax.imageio.ImageIO; import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import sudoku.Sudoku; import sudoku.SudokuEvent; import sudoku.SudokuListener; import sudokuSolver.SolvedSquare; import sudokuSolver.Solver; /** * <p>class <code>Mui</code> does most of the GUI work and implements the * main frame of the application.<br> * Creates the menu and hanldes it's events (implementing * <code>ActionListener</code> interface).<br>Initialises all the components</p> * * @see GamePanel * @see MStatusPanel * @author Visvardis Marios * */ @SuppressWarnings("serial") public class Mui extends JFrame implements ActionListener { // Visual Components private JMenuBar menuBar = new JMenuBar(); private JLabel label; private JPanel superPanel; private GamePanel panel; private MStatusPanel statusPanel; private JPanel newCustomPanel; private JPanel southPanel; private JPanel titlePanel; private JPanel middle; private MSolvePanel msp; private JButton save; private JButton savenopen; private JButton cancel; private JButton getStr; // game represents the game currently processed and displayed private Sudoku game; private Sudoku virgin; // A untouched copy of the original game // Solver private Solver solver; // Holding the path of the last saved file or null if not defined private String saveName; // preloaded private Vector<String> preloaded; private Vector<String> preloadedNames; private Settings settings; private String version; // For the Menu private JMenu fileMenu; private JMenu viewMenu; private JMenu solverMenu; private JMenu aboutMenu; private JMenu newMenu; private JMenuItem newCustomM; private JMenuItem newM; private JMenuItem openM; private JMenu openPresetM; JMenuItem[] preMenuItems; private JMenuItem saveAsM; private JMenuItem restartM; private JMenuItem closeM; private JMenuItem printM; private JMenuItem exitM; private JCheckBoxMenuItem showSolvePanelM; private JCheckBoxMenuItem showTraceM; private JCheckBoxMenuItem showTTM; private JMenuItem clearMarksM; private JMenuItem saveThemeM; private JMenuItem loadThemeM; private JMenuItem loadDefaultThemeM; private JMenuItem saveDefaultM; private JMenuItem prefsM; private JMenuItem undoM; private JMenuItem redoM; private JMenuItem hintM; private JMenuItem solveAtOnceM; private JMenuItem solveM; private JMenuItem aboutM; /** * Mui - Constructor * All the work is done in initComponents, createMenu, initSettings * is loaded or created. * */ public Mui(){ setIcon(); initSettings(); createMenu(); initComponents(); loadSettings(settings); setVisible(false); } public void setVersion(String version) { this.version = version; } private void initSettings(){ settings = new Settings(); //获取用户的主目录 String home = System.getProperty("user.home"); System.out.println(home); String fileDIR = new String(home + File.separator +"MUSoSu"); File f = new File(fileDIR); if(f.exists()){ String fileURI = new String(fileDIR + File.separator + "settings.xml"); if(new File(fileURI).exists()){ settings.loadFromFile(fileURI); } }else{ ClassLoader cl = this.getClass().getClassLoader(); InputStream in = cl.getResourceAsStream("default.xml"); settings.loadFromFile(in); } } private void loadSettings(Settings s){ panel.setFixedBackColor(s.getFixedBackColor()); panel.setHighlightColor(s.getHighlightColor()); panel.setSquareBackColor(s.getButtonBackColor()); panel.setErrorBackColor(s.getErrorBackColor()); panel.setPanelBackColor(s.getPanelBackColor()); panel.setShowTrace(s.getShowTrace()); panel.setShowToolTip(s.getShowToolTip()); panel.setMarkColorA(s.getMarkColorA()); panel.setMarkColorB(s.getMarkColorB()); panel.setMarkColorC(s.getMarkColorC()); panel.setMarkColorD(s.getMarkColorD()); showTraceM.setState(s.getShowTrace()); showTTM.setState(s.getShowToolTip()); } private void setIcon(){ try{ ClassLoader loader = this.getClass().getClassLoader(); InputStream imStream = loader.getResourceAsStream("musosu.png"); Image img = ImageIO.read(imStream); setIconImage(img); }catch(Exception e){ System.out.println("Could not load icon"); } } private void registerGameListener(Sudoku s){ s.addSudokuListener(new SudokuListener(){ public void sudokuChanged(SudokuEvent e){ sudokuChangedEvent(e); } }); } private void initSudoku(){ virgin = new Sudoku(game); solver = new Solver(); registerGameListener(game); game.fireSudokuEvent(SudokuEvent.SUDOKU_CHANGED); statusPanel.startTimer(); panel.loadBoard(game); solver.setGame(game); game.setDifficulty(solver.estimateDifficulty()); statusPanel.setDifficulty(game.getDifficulty()); newCustomPanel.setVisible(false); restartM.setEnabled(true); closeM.setEnabled(true); saveAsM.setEnabled(true); printM.setEnabled(true); showSolvePanelM.setEnabled(true); hintM.setEnabled(true); solveM.setEnabled(true); solveAtOnceM.setEnabled(true); if(msp.isVisible()){ msp.setSudoku(game); } panel.panelResized(); } // EVENT HANDLING METHODS public void actionPerformed(ActionEvent evt){ if(evt.getSource() == newM) newMenuEvent(evt); else if(evt.getSource() == newCustomM) newCustomMenuEvent(evt); else if(evt.getSource() == openM) openMenuEvent(evt); else if(evt.getSource() == restartM) restartMenuEvent(evt); else if(evt.getSource() == closeM) closeMenuEvent(evt); else if(evt.getSource() == saveAsM) saveAsMenuEvent(evt); else if(evt.getSource() == printM) printMenuEvent(evt); else if(evt.getSource() == exitM) exitMenuEvent(evt); else if(evt.getSource() == clearMarksM) panel.unmarkAll(); else if(evt.getSource() == loadThemeM) loadThemeMenuEvent(evt); else if(evt.getSource() == loadDefaultThemeM) loadDefaultThemeMenuEvent(evt); else if(evt.getSource() == saveThemeM) saveThemeMenuEvent(evt); else if(evt.getSource() == saveDefaultM) saveDefaultMenuEvent(evt); else if(evt.getSource() == prefsM) prefsMenuEvent(evt); else if(evt.getSource() == undoM) panel.undo(); else if(evt.getSource() == redoM) panel.redo(); else if(evt.getSource() == hintM) hintMenuEvent(evt); else if(evt.getSource() == solveAtOnceM) solveAtOnceMenuEvent(evt); else if(evt.getSource() == solveM) solveMenuEvent(evt); else if(evt.getSource() == aboutM) aboutMenuEvent(evt); // Events from newCustomPanel Buttons else if(evt.getSource() == getStr) getStrEvent(); else if(evt.getSource() == cancel) closeMenuEvent(evt
评论
    相关推荐
    • SVM 算法 java 实现
      SVM 算法 java 实现了调用接口,只要传入数据即可,调用了encog这个开源包的SVM算法,也是官方libsvm的。
    • 经典算法Java实现
      包括JAVA的经典算法和实现,用于JAVA的学习和研究
    • 遗传算法java工程
      工程利用遗传算法解决多路复用器的模拟状态,里面有充分的技术文档(英语)以及代码注释,自己写的,用不到了以后。贡献出来给大家。
    • LRU算法 java实现
      LRU算法java实现
    • 国密算法java实现
      国家商用密码管理局公布的标准国密算法SM4的算法实现哦
    • 遗传算法java实现
      本代码为Java实现的遗传算法,压缩包中有详细的说明,希望对各位有帮助
    • SVM 算法 java版本
      SVM 算法 java 实现了调用接口,只要传入数据即可,调用了encog这个开源包的SVM算法,也是官方libsvm的。
    • AHP算法java实现
      java实现AHP算法,包括文档说明,算法介绍等ppt文档 欢迎使用
    • DES算法Java实现
      DES算法Java代码实现,适用于学生交作业
    • tomasulo算法java实现
      自己用java实现的一个简单的tomasulo算法的实现对,并且做了界面,有助于对tomasulo算法有一个更好的了解