【Java精品源码栏目提醒】:网学会员在Java精品源码频道为大家收集整理了“连连看java源代码(练习) - 其它资料“提供大家参考,希望对大家有所帮助!
连连看 java 源代码import javax.swing.import java.awt.import java.awt.event.public class lianliankan implements ActionListenerJFrame mainFrame //主面板Container thisContainerJPanel centerPanelsouthPanelnorthPanel //子面板JButton diamondsButton new JButton65//游戏按钮数组JButton exitButtonresetButtonnewlyButton //退出,重列,重新开始按钮JLabel fractionLablenew JLabel0 //分数标签JButton firstButtonsecondButton //分别记录两次被选中的按钮int grid new int87//储存游戏按钮位置static boolean pressInformationfalse //判断是否有按钮被选中int x00y00x0y0fristMsg0secondMsg0validateLV //游戏按钮的位置坐标int ijkn//消除方法控制public void initmainFramenew JFrameJKJ 连连看thisContainer mainFrame.getContentPanethisContainer.setLayoutnew BorderLayoutcenterPanelnew JPanelsouthPanelnew JPanelnorthPanelnew JPanelthisContainer.addcenterPanelCenterthisContainer.addsouthPanelSouththisContainer.addnorthPanelNorthcenterPanel.setLayoutnew GridLayout65forint cols 0cols 6colsforint rows 0rows 5rows diamondsButtoncolsrowsnew JButtonString.valueOfgridcols1rows1diamondsButtoncolsrows.addActionListenerthiscenterPanel.adddiamondsButtoncolsrowsexitButtonnew JButton退出exitButton.addActionListenerthisresetButtonnew JButton重列resetButton.addActionListenerthisnewlyButtonnew JButton再来一局newlyButton.addActionListenerthissouthPanel.addexitButtonsouthPanel.addresetButtonsouthPanel.addnewlyButtonfractionLable.setTextString.valueOfInteger.parseIntfractionLable.getTextnorthPanel.addfractionLablemainFrame.setBounds280100500450mainFrame.setVisibletruepublic void randomBuild int randomscolsrowsforint twins1twins