双色球软件设计思路及初步源码

软件功能:

一.双色球共1107568注二等奖,这些注里可以过滤掉的垃圾号如下:

1.六连号、五连号、四连号、三连号、甚至二连号

2.全偶数、全气数奇数

3.已经开过的奖号

4.已经开过的奖号的五重号、四重号、三重号

所谓垃圾号很多,可以逐步增加,但双色球开奖正常的号码我们假设以三奇三偶、大小均匀为主。


二.一旦过滤掉很多垃圾号之后,你就可以豪赌一把!

三.基本开奖号码查询

1.可以按位查询,点击后可以排序

2.选定一些注数后让选定的行为红色,可以再排序,但红色行不变。

3.可以查询当前开了多少期,过滤后还剩余多少注。

以上为本人对此软件的基本思路,有兴趣的朋友可以增加思路、增加功能(当然,我写的源码会公开),中奖事儿小,学习java的事儿也不大,娱乐,娱乐!

A.主运行程序:

import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.Image; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.AbstractButton; import javax.swing.ImageIcon; import javax.swing.JButton; 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.JToolBar; import javax.swing.SwingConstants; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; public class SSQ { JFrame frame; JPanel KJpanel,GLpanel,JGpanel; ImageIcon icon01; public SSQ(){ frame = new JFrame("大话双色球"); Image image = Toolkit.getDefaultToolkit().createImage(""); frame.setIconImage(image); frame.setJMenuBar(createMenuBar()); frame.setContentPane(createContentPane()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocation(50,50); frame.setSize(800,500); frame.setVisible(true); } private Container createContentPane() { Container contentPane = frame.getContentPane(); JToolBar toolBar = new JToolBar(); JLabel KT = new JLabel("开头:"); KT.setFont(new Font("微软雅黑",Font.BOLD, 14)); KJpanel = new JPanel(); KJpanel.setSize(100, 100); KJpanel.setBorder(new TitledBorder("开奖")); KJpanel.add(new ReadKj()); GLpanel = new JPanel(); GLpanel.setBorder(new TitledBorder("过滤")); JGpanel = new JPanel(); JGpanel.setBorder(new TitledBorder("结果")); JButton button01 = new JButton("01",icon01); button01.setHorizontalTextPosition(AbstractButton.CENTER); button01.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { GLpanel.removeAll(); GLpanel.add(new Read01()); GLpanel.updateUI(); } }); System.gc(); JButton button02 = new JButton("02",icon01); button02.setHorizontalTextPosition(AbstractButton.CENTER); button02.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { GLpanel.removeAll(); GLpanel.add(new Read02()); GLpanel.updateUI(); } }); System.gc(); JButton button03 = new JButton("03",icon01); button03.setHorizontalTextPosition(AbstractButton.CENTER); JButton button04 = new JButton("04",icon01); button04.setHorizontalTextPosition(AbstractButton.CENTER); JButton button05 = new JButton("05",icon01); button05.setHorizontalTextPosition(AbstractButton.CENTER); JButton button06 = new JButton("06",icon01); button06.setHorizontalTextPosition(AbstractButton.CENTER); JButton button07 = new JButton("07",icon01); button07.setHorizontalTextPosition(AbstractButton.CENTER); JButton button08 = new JButton("08",icon01); button08.setHorizontalTextPosition(AbstractButton.CENTER); JButton button09 = new JButton("09",icon01); button09.setHorizontalTextPosition(AbstractButton.CENTER); JButton button10 = new JButton("10-28",icon01); button10.setHorizontalTextPosition(AbstractButton.CENTER); toolBar.add(KT); toolBar.add(button01); toolBar.add(button02); toolBar.add(button03); toolBar.add(button04); toolBar.add(button05); toolBar.add(button06); toolBar.add(button07); toolBar.add(button08); toolBar.add(button09); toolBar.add(button10); contentPane.add(toolBar,BorderLayout.NORTH); contentPane.add(GLpanel,BorderLayout.CENTER); contentPane.add(JGpanel,BorderLayout.EAST); contentPane.add(KJpanel,BorderLayout.WEST); return contentPane; } private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("关于(a)"); JMenuItem menuItem1 = new JMenuItem("关于(a)"); JMenuItem menuItem2 = new JMenuItem("退出(F4)"); menuItem2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String message = "确实要退出系统吗?"; String title = "确认对话框"; int messageType = JOptionPane.INFORMATION_MESSAGE; int optionType = JOptionPane.YES_NO_OPTION; int option = JOptionPane.showConfirmDialog(frame, message,title,optionType,messageType); if(option == JOptionPane.YES_OPTION){ System.exit(0); } } }); icon01= new ImageIcon("icon/021.png"); menuBar.add(menu); menu.add(menuItem1); menu.add(menuItem2); return menuBar; } public static void main(String[] args) { new SSQ(); } }
B.设置表格颜色类:

import java.awt.Color; import java.awt.Component; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; public class RowRenderer extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable t, Object value, boolean isSelected, boolean hasFocus, int row, int column) { //设置奇偶行的背景色,可在此根据需要进行修改 if (row == 0){ setForeground(Color.BLUE); } if(row == 7){ setForeground(Color.BLUE); } return super.getTableCellRendererComponent(t, value, isSelected, hasFocus, row, column); } }
C.读入开奖数据类

import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Vector; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.RowFilter; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; public class ReadKj extends JPanel{ JLabel labelZhu; JTable table; FileReader reader = null; BufferedReader br = null; Vector<Vector> rowData = null; public ReadKj(){ Vector<String> col = new Vector<String>(); col.addElement("期号"); col.addElement("1"); col.addElement("2"); col.addElement("3"); col.addElement("4"); col.addElement("5"); col.addElement("6"); col.addElement("蓝球"); try{ String txt = "kj.txt"; reader = new FileReader(txt); br = new BufferedReader(reader); String eachLine = null; rowData = new Vector<Vector>(); while((eachLine = br.readLine()) != null){ String[] temp = eachLine.split(" "); Vector<String> row = new Vector<String>(); for(int i = 0; i < temp.length; i++){ row.add(temp[i]); } rowData.add(row);//再把每一个row的数据给rowData } reader.close(); br.close(); }catch(FileNotFoundException e){ String message = "读取01开关文件未找到!"; String title = "文件错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); }catch(IOException e){ String message = "读取错误,你是否打开多个文件?"; String title = "读取错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); }catch(OutOfMemoryError e){ String message = "读取错误,你是否打开多个文件?"; String title = "读取错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); }finally{ try{ reader.close(); br.close(); }catch(FileNotFoundException e){ String message = "读取01开关文件未找到!"; String title = "文件错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); }catch(IOException e){ String message = "读取错误,你是否打开多个文件?"; String title = "读取错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); }catch(OutOfMemoryError e){ String message = "读取错误,你是否打开多个文件?"; String title = "读取错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); } } DefaultTableModel model = new DefaultTableModel(rowData,col){ public Class getColumnClass(int column) { Class returnValue; if ((column >= 0) && (column < getColumnCount())) { returnValue = getValueAt(0, column).getClass(); } else { returnValue = Object.class; } return returnValue; } }; table = new JTable(model); final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter);//设置排序 TableColumn col0 = table.getColumnModel().getColumn(0);//第一列 col0.setPreferredWidth(150); col0.setCellRenderer(new RowRenderer()); TableColumn col7 = table.getColumnModel().getColumn(7);//最后一列 col7.setCellRenderer(new RowRenderer()); table.setSelectionForeground(Color.red);//选择时的颜色 table.setPreferredScrollableViewportSize(new Dimension(300,400)); JScrollPane scrollPane = new JScrollPane(table); this.setLayout(new BorderLayout()); JPanel panelTable = new JPanel(); panelTable.add(scrollPane); JPanel panelLabel = new JPanel(); JLabel labelZhushu = new JLabel("至今开奖期数:"); labelZhu = new JLabel(); labelZhu.setText(""+(table.getRowCount())); panelLabel.add(labelZhushu); panelLabel.add(labelZhu); JPanel panelBianji = new JPanel(); final JTextField text1 = new JTextField(10); JButton buttonGL = new JButton("查询"); buttonGL.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String text = text1.getText(); if (text.length() == 0) { sorter.setRowFilter(null); labelZhu.setText(""+(table.getRowCount())); } else { sorter.setRowFilter(RowFilter.regexFilter(text)); labelZhu.setText(""+(table.getRowCount())); } } }); panelBianji.add(text1); panelBianji.add(buttonGL); panelLabel.add(panelBianji); this.add(panelTable,BorderLayout.NORTH); this.add(panelLabel,BorderLayout.SOUTH); //this.add(panelBianji,panelLabel.BOTTOM_ALIGNMENT); } }
D.读入01开奖号码类

import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Vector; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.border.Border; import javax.swing.border.TitledBorder; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; public class Read01 extends JPanel{ FileReader reader = null; BufferedReader br = null; Vector<Vector> rowData = null; JTable table ; public Read01(){ Vector<String> col = new Vector<String>(); col.addElement("1"); col.addElement("2"); col.addElement("3"); col.addElement("4"); col.addElement("5"); col.addElement("6"); try{ String txt = "01.txt"; reader = new FileReader(txt); br = new BufferedReader(reader); String eachLine = null; rowData = new Vector<Vector>(); while((eachLine = br.readLine()) != null){ String[] temp = eachLine.split(" "); Vector<String> row = new Vector<String>(); for(int i = 0; i < temp.length; i++){ row.add(temp[i]); } rowData.add(row);//再把每一个row的数据给rowData } reader.close(); br.close(); }catch(FileNotFoundException e){ String message = "读取01数据文件未找到!"; String title = "文件错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); }catch(IOException e){ String message = "读取错误,你是否打开多个文件?"; String title = "读取错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); }catch(OutOfMemoryError e){ String message = "读取错误,你是否打开多个文件?"; String title = "读取错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); }finally{ try{ reader.close(); br.close(); }catch(FileNotFoundException e){ String message = "读取01开关文件未找到!"; String title = "文件错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); }catch(IOException e){ String message = "读取错误,你是否打开多个文件?"; String title = "读取错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); }catch(OutOfMemoryError e){ String message = "读取错误,你是否打开多个文件?"; String title = "读取错误"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(this, message,title,messageType); } } DefaultTableModel model = new DefaultTableModel(rowData,col); table = new JTable(model); TableColumn col0 = table.getColumnModel().getColumn(0);//第一列 TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter);//设置排序 table.setSelectionBackground(Color.green);//选择时的颜色 table.setPreferredScrollableViewportSize(new Dimension(200,400)); JScrollPane scrollPane = new JScrollPane(table); this.setLayout(new BorderLayout()); JPanel panel = new JPanel();//整体panel panel.setLayout(new BorderLayout()); JPanel panelTable = new JPanel();//表格panel panelTable.add(scrollPane); JPanel panelCheckBox = new JPanel();//选择器panel panelCheckBox.setBorder(new TitledBorder("去掉")); panelCheckBox.setLayout(new GridLayout(0,1)); JCheckBox check6 = new JCheckBox("6连号"); JCheckBox check5 = new JCheckBox("5连号"); JCheckBox check4 = new JCheckBox("4连号"); JCheckBox check3 = new JCheckBox("3连号"); JCheckBox check2 = new JCheckBox("2连号"); panelCheckBox.add(check6); panelCheckBox.add(check5); panelCheckBox.add(check4); panelCheckBox.add(check3); panelCheckBox.add(check2); JPanel panelLabel = new JPanel(); JLabel labelZhu = new JLabel(); labelZhu.setText(""+(table.getRowCount()+1)); JLabel labelZhushu = new JLabel("总计注数:" ); panelLabel.add(labelZhushu); panelLabel.add(labelZhu); panel.add(panelTable,BorderLayout.WEST); panel.add(panelCheckBox,BorderLayout.EAST); panel.add(panelLabel,BorderLayout.SOUTH); this.add(panel); } }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值