Untitled

Run Settings
LanguageJava
Language Version
Run Command
import java.awt.BorderLayout; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import java.awt.FlowLayout; import java.awt.Dimension; import java.awt.Color; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.JLabel; import java.awt.Font; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashSet; import java.util.Random; import javax.swing.JTextField; import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.JButton; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Lotty extends JFrame implements ActionListener { JPanel contentPane; JTextField tf手動輸入; JTextField tf1; JTextField tf2; JTextField tf3; JTextField tf4; JTextField tf5; JTextField tf6; JButton btn確定; JButton btn清除; JButton btn開獎; JButton btn電腦選號; JTextField text規則; JTextField text開獎號碼; JTextField textField_8; HashSet<Integer> array; JButton jbt[]; /** * Launch the application. */ public static void main(String[] args) { Lotty frame = new Lotty(); frame.setVisible(true); } /** * Create the frame. */ public Lotty() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 696, 701); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); JPanel pan1 = new JPanel(); pan1.setBackground(new Color(255, 248, 220)); pan1.setPreferredSize(new Dimension(10, 150)); contentPane.add(pan1, BorderLayout.NORTH); JLabel lblNewLabel = new JLabel("\u624B\u52D5\u8F38\u5165\u865F\u78BC"); lblNewLabel.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); JLabel lblenter = new JLabel("\u8ACB\u8F38\u51651-49\u4E14\u6309enter"); lblenter.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); tf手動輸入 = new JTextField(); tf手動輸入.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); tf手動輸入.setColumns(10); tf手動輸入.addActionListener(this); JLabel label = new JLabel("\u865F\u78BC"); label.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); tf1 = new JTextField(); tf1.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); tf1.setColumns(10); tf2 = new JTextField(); tf2.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); tf2.setColumns(10); tf3 = new JTextField(); tf3.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); tf3.setColumns(10); tf4 = new JTextField(); tf4.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); tf4.setColumns(10); tf5 = new JTextField(); tf5.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); tf5.setColumns(10); tf6 = new JTextField(); tf6.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); tf6.setColumns(10); JButton btn電腦選號 = new JButton("\u96FB\u8166\u9078\u865F"); btn電腦選號.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); btn電腦選號.addActionListener(this); btn確定 = new JButton("\u78BA\u5B9A"); btn確定.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); btn清除 = new JButton("\u6E05\u9664"); btn清除.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); GroupLayout gl_pan1 = new GroupLayout(pan1); gl_pan1.setHorizontalGroup( gl_pan1.createParallelGroup(Alignment.LEADING) .addGroup(gl_pan1.createSequentialGroup() .addGap(18) .addGroup(gl_pan1.createParallelGroup(Alignment.LEADING) .addComponent(lblNewLabel) .addComponent(label)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_pan1.createParallelGroup(Alignment.LEADING) .addGroup(gl_pan1.createSequentialGroup() .addComponent(tf手動輸入, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(5) .addComponent(lblenter, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_pan1.createSequentialGroup() .addComponent(tf1, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(tf2, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(tf3, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(tf4, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(tf5, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(tf6, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_pan1.createSequentialGroup() .addComponent(btn電腦選號, GroupLayout.PREFERRED_SIZE, 109, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(btn確定, GroupLayout.PREFERRED_SIZE, 109, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(btn清除, GroupLayout.PREFERRED_SIZE, 109, GroupLayout.PREFERRED_SIZE))) .addContainerGap(197, Short.MAX_VALUE)) ); gl_pan1.setVerticalGroup( gl_pan1.createParallelGroup(Alignment.LEADING) .addGroup(gl_pan1.createSequentialGroup() .addContainerGap() .addGroup(gl_pan1.createParallelGroup(Alignment.LEADING) .addComponent(tf手動輸入, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblenter, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE) .addComponent(lblNewLabel)) .addGap(18) .addGroup(gl_pan1.createParallelGroup(Alignment.LEADING) .addComponent(label, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE) .addComponent(tf1, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE) .addComponent(tf2, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE) .addComponent(tf3, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE) .addComponent(tf4, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE) .addComponent(tf5, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE) .addComponent(tf6, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_pan1.createParallelGroup(Alignment.LEADING) .addComponent(btn電腦選號) .addComponent(btn確定, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) .addComponent(btn清除, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)) .addContainerGap(18, Short.MAX_VALUE)) ); pan1.setLayout(gl_pan1); // 動態button~ JPanel panel2 = new JPanel(); panel2.setBackground(new Color(255, 248, 220)); panel2.setBackground(new Color(255, 248, 220)); panel2.setLayout(new GridLayout(0,7)); JButton[] jbt = new JButton[49]; for(int i=0;i<=48;i++) { jbt[i]=new JButton(); jbt[i].setSize(1,1); jbt[i].setText(Integer.toString(i+1)); jbt[i].addActionListener( this ); jbt[i].setActionCommand(i+1+" "); panel2.add(jbt[i]); } contentPane.add(panel2, BorderLayout.CENTER); //動態按鈕 JPanel panel3 = new JPanel(); panel3.setBackground(new Color(255, 248, 220)); panel3.setPreferredSize(new Dimension(10, 250)); contentPane.add(panel3, BorderLayout.SOUTH); btn開獎 = new JButton("\u958B\u734E123~"); btn開獎.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); text規則 = new JTextField(); text規則.setEditable(false); text規則.setBackground(new Color(255, 228, 225)); text規則.setAutoscrolls(false); text規則.setColumns(10); text開獎號碼 = new JTextField(); text開獎號碼.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); text開獎號碼.setColumns(10); text開獎號碼.setBackground(new Color(255, 228, 225)); text開獎號碼.setAutoscrolls(false); textField_8 = new JTextField(); textField_8.setEditable(false); textField_8.setBackground(new Color(255, 228, 225)); textField_8.setFont(new Font("微軟正黑體", Font.PLAIN, 16)); textField_8.setText("\u60A8\u9078\u64C7\u7684\u865F\u78BC"); textField_8.setColumns(10); GroupLayout gl_panel3 = new GroupLayout(panel3); gl_panel3.setHorizontalGroup( gl_panel3.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel3.createSequentialGroup() .addGap(20) .addGroup(gl_panel3.createParallelGroup(Alignment.LEADING) .addComponent(text規則, GroupLayout.PREFERRED_SIZE, 256, GroupLayout.PREFERRED_SIZE) .addComponent(btn開獎, GroupLayout.PREFERRED_SIZE, 109, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED, 70, Short.MAX_VALUE) .addGroup(gl_panel3.createParallelGroup(Alignment.LEADING) .addComponent(textField_8, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE) .addComponent(text開獎號碼, GroupLayout.PREFERRED_SIZE, 287, GroupLayout.PREFERRED_SIZE)) .addContainerGap(37, Short.MAX_VALUE)) ); gl_panel3.setVerticalGroup( gl_panel3.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel3.createSequentialGroup() .addContainerGap() .addGroup(gl_panel3.createParallelGroup(Alignment.BASELINE) .addComponent(btn開獎, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) .addComponent(textField_8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panel3.createParallelGroup(Alignment.LEADING) .addComponent(text規則, GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE) .addComponent(text開獎號碼, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); panel3.setLayout(gl_panel3); } public void actionPerformed(ActionEvent e) { //實作方法囉 if (e.getSource() == tf手動輸入) tf1.setText("1"); else if (e.getSource() == jbt) { tf2.setText("3"); } } }
Editor Settings
Theme
Key bindings
Full width
Lines