1.java课程设计源代码(急!项目项目!源码源码!大全!项目项目惠州里深圳源码)
2.java:求一个用swing来做小程序,源码源码我是大全怎么找安卓源码用来修改配置文件用的,求代码谢谢
java课程设计源代码(急!项目项目!源码源码!大全!项目项目)
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;
public class game extends JFrame {
private JLabel label_2;
private int number;
private int sum;
final JLabel label = new JLabel();
final JLabel label_1 = new JLabel();
public static void main(String[] args) {
new game();
}
public game() {
super("点?!源码源码");
getContentPane().setLayout(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JButton button = new JButton();
button.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent arg0) {
onClick();
}
});
button.setText("出牌");
button.setBounds(,大全 , , );
getContentPane().add(button);
label.setBorder(new LineBorder(Color.black, 1, false));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(new Font("", Font.BOLD, ));
label.setText("背面");
label.setBounds(, , , );
getContentPane().add(label);
label_1.setText("你已经拥有的牌:");
label_1.setBounds(, , , );
getContentPane().add(label_1);
this.setBounds(, , , );
this.setVisible(true);
getContentPane().add(getLabel_2());
}
public int randNumber() {
try {
Thread.sleep();
} catch (InterruptedException e) {
e.printStackTrace();
}
return (int) (Math.random() * + 1);
}
public void onClick() {
number = this.randNumber();
this.sum += number;
label.setText("" + number);
String strTemp = this.label_1.getText();
strTemp += "" + number + " ";
label_1.setText(strTemp);
String temp = "合计:" + sum;
label_2.setText(temp);
isWin();
}
public void isWin() {
if (sum > ) {
JOptionPane.showMessageDialog(this, "你输了");
clear();
return;
} else if (sum == ) {
JOptionPane.showMessageDialog(this, "你赢了");
clear();
return;
} else {
int i = JOptionPane.showOptionDialog(this, "是否继续?", "提示",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, null, null);
if (i == JOptionPane.OK_OPTION) {
onClick();
} else
return;
}
}
private void clear() {
label_2.setText("合计:");
sum = 0;
number = 0;
label_1.setText("你已经拥有的牌:");
}
/
*** @return
*/
protected JLabel getLabel_2() {
if (label_2 == null) {
label_2 = new JLabel();
label_2.setText("合计:");
label_2.setBounds(, , , );
}
return label_2;
}
}
真好无聊中。。项目项目用什么应用改源码
java:求一个用swing来做小程序,源码源码我是大全用来修改配置文件用的,求代码谢谢
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public class Test extends JFrame {
private JPanel jp = new JPanel();
private JButton jb = new JButton("按钮一");
private JButton jb = new JButton("按钮二");
private JButton jb = new JButton("按钮三");
private JButton[] jb = new JButton[] { jb,小程序源码如何获得 jb, jb };
private JLabel jl = new JLabel("请单击按钮!");
private int count = 0;
public Test() {
for (int i = 0; i < jb.length; i++) {
jp.add(jb[i]);
}
jp.add(jl);
this.add(jp);
this.setTitle("点按钮,记录单击按钮的次数和名字!");
jb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Test.this.jl.setText(jl.getText());
}
});
for (int i = 0; i < jb.length; i++) {
jb[i].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if (e.getSource() == jb) {
Test.this.jl.setText("您单击的君赞源码咖片是按钮一,您总共单机了" + (++count)
+ "次按钮");
} else if (e.getSource() == jb) {
Test.this.jl.setText("您单击的是按钮二,您总共单机了" + (++count)
+ "次按钮");
} else if (e.getSource() == jb) {
Test.this.jl.setText("您单击的是按钮三,您总共单机了" + (++count)
+ "次按钮");
}
}
});
this.setBounds(, , , );
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
public static void main(String[] args) {
new Test();
}
}