-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui
More file actions
133 lines (115 loc) · 3.54 KB
/
Copy pathgui
File metadata and controls
133 lines (115 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package qipan;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by k70 on 2017-06-07.
*/
public class QiGui extends JFrame{
private fgai Data;
private int[][] PaintData;
private Pain pp=new Pain();
private int x;
private int y;
private JTextField Tx=new JTextField();
private JTextField Ty=new JTextField();
private JButton OneStep=new JButton("OneStep");
private JButton Revos=new JButton("Revoke");
private JTextField Jtext=new JTextField();
public QiGui(){
x=-1;
y=-1;
pp.setData(PaintData);
JPanel Bu1=new JPanel(new GridLayout(1,2));
Bu1.add(OneStep);
Bu1.add(Revos);
JPanel PN=new JPanel(new GridLayout(1,2));
PN.add(new JLabel("请输入K:"));
PN.add(Jtext);
JPanel Pxy=new JPanel(new GridLayout(1,3));
Pxy.add(new JLabel("请输入X,Y:"));
Pxy.add(Tx);
Pxy.add(Ty);
setLayout(new GridLayout(4,1));
add(PN);
add(Pxy);
add(pp);
add(Bu1);
Tx.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
x=new Integer(Tx.getText()).intValue();
if(x!=-1&&y!=-1)
Data.Inkk(x,y);
}
});
Ty.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
y=new Integer(Ty.getText()).intValue();
if(x!=-1&&y!=-1)
Data.Inkk(x,y);
}
});
OneStep.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Data.Increase();
pp.repaint();
}
});
Revos.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Data.Revoke();
pp.repaint();
}
});
Jtext.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int x=new Integer(Jtext.getText()).intValue();
x=new Double(Math.pow(2,x)).intValue();
Data=new fgai(x);
}
});
}
public static void main(String args[]){
QiGui frame=new QiGui();
frame.setTitle("Qipan");
frame.setSize(800,800);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class Pain extends JPanel {
private int[][] data;
public void setData(int[][] a) {
data = a;
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int a=25;
g.setColor(Color.YELLOW);
for(int i=0;i<data.length;i++){
for(int j=0;j<data[0].length;j++){
if(data[i][j]==1)
g.setColor(Color.YELLOW);
g.fillRect(a*i,a*j,a,a);
if(data[i][j]==-1){
g.setColor(Color.RED);
g.fillRect(a*i,a*j,a,a);
}
}
}
g.setColor(Color.BLACK);
for(int ii=0;ii<=data.length;ii++){
g.drawLine(0,a*ii,a*data[0].length,a*ii);
}
for(int j=0;j<=data[0].length;j++){
g.drawLine(j*a,0,j*a,a*data.length);
}
}
}