1.java课程设计源代码(急!画笔画笔!源码!工具!画笔画笔cf助手网页源码)
2.求Java记事本源代码
3.你好,源码可以麻烦你帮我写个实现下图功能的工具源码发现商用java源码吗,谢谢(ps:我的画笔画笔财富值是零,实在抱歉...)
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(,画笔画笔电视源码php , , );
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记事本源代码
自己写的工具,能实现基本功能:
import java.awt.BorderLayout;
import java.awt.FileDialog;
import java.awt.Font;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.TitledBorder;
/*因为根据个人的电脑路径可能有所偏差,没有源路径的nike下单源码情况下,设置默认保存路径为D盘根目录下
* 若要选择保存其他地方,可以选择 另存为*/
public class TestDemo extends JFrame {
private static final long serialVersionUID = -L;
private String url = null;//文件路径
private String str=null;//复制或剪切 的字符串
private StringSelection stringSelection=null;
private Clipboard clipboard=new Clipboard(str);
private Transferable transferable=null;
private DataFlavor flavor=null;
public TestDemo() {
init();
}
private void init() {
setTitle("我的记事本");
setSize(, );
setContentPane(createContentPane());//添加主面板
}
/*创建主面板*/
private JPanel createContentPane() {
JPanel pane = new JPanel(new BorderLayout());
pane.add(BorderLayout.NORTH, createChocePane());//添加菜单栏
pane.add(createAreaPane());//添加文本编辑区域
return pane;
}
/*创建菜单栏,以及实现功能*/
private JPanel createChocePane() {
JPanel pane = new JPanel();
JMenuBar menuBar1 = new JMenuBar();
JMenu menu = new JMenu("文件");
menuBar1.add(menu);
JMenuItem menuIt1 = new JMenuItem("新建");
JMenuItem menuIt2 = new JMenuItem("打开");
JMenuItem menuIt3 = new JMenuItem("保存");
JMenuItem menuIt4 = new JMenuItem("另存为");
menu.add(menuIt1);
menu.add(menuIt2);
menu.add(menuIt3);
menu.add(menuIt4);
JMenuBar menuBar2 = new JMenuBar();
JMenu menu2 = new JMenu("编辑");
menuBar2.add(menu2);
JMenuItem menuIt5 = new JMenuItem("复制");
JMenuItem menuIt6 = new JMenuItem("剪切");
JMenuItem menuIt7 = new JMenuItem("粘帖");
menu2.add(menuIt5);
menu2.add(menuIt6);
menu2.add(menuIt7);
JMenuBar menuBar3 = new JMenuBar();
JMenu menu3 = new JMenu("帮助");
menuBar3.add(menu3);
JMenuItem menuIt8 = new JMenuItem("关于记事本");
menu3.add(menuIt8);
pane.add(menuBar1);
pane.add(menuBar2);
pane.add(menuBar3);
menuIt1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
testArea.setText(null);
}
});
menuIt2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
final FileDialog fd = new FileDialog(new JFrame(),获得源码资本 "查找文件",
FileDialog.LOAD);
fd.setVisible(true);
if (fd.getDirectory() != null && fd.getFile() != null) {
testArea.setText(null);
url = fd.getDirectory() + fd.getFile();
try {
BufferedReader in = new BufferedReader(new FileReader(
url));
for (int i = 0;; i++) {
testArea.append(in.readLine());
if (in.read() == -1) {
break;
} else
continue;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
menuIt3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (url==null) {
url="D:\\新建 文本文档.txt";
}
File f = new File(url);
BufferedWriter out = null;
try {
out = new BufferedWriter(new FileWriter(url));
f.createNewFile();
out.append(testArea.getText());
out.flush();
} catch (IOException e1) {
e1.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
});
menuIt4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
FileDialog fd = new FileDialog(new JFrame(), "保存文本",
FileDialog.SAVE);
fd.setVisible(true);
if (url!=null) {
File f = new File(url);
BufferedWriter out = null;
try {
f.createNewFile();
out = new BufferedWriter(new FileWriter(url));
out.append(testArea.getText());
out.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
});
menuIt5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
str=testArea.getSelectedText();
stringSelection=new StringSelection(str);
clipboard.setContents(stringSelection, null);
}
});
menuIt6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
str=testArea.getSelectedText();
stringSelection=new StringSelection(str);
clipboard.setContents(stringSelection, null);
int start=testArea.getSelectionStart();
int end=testArea.getSelectionEnd();
testArea.replaceRange( null,start,end);
}
});
menuIt7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
transferable=clipboard.getContents(this);
flavor=DataFlavor.stringFlavor;
if (transferable.isDataFlavorSupported(flavor)) {
int start=testArea.getSelectionStart();
int end=testArea.getSelectionEnd();
testArea.replaceRange( null,start,end);
int pos=testArea.getCaretPosition();
try {
str=(String)transferable.getTransferData(flavor);
testArea.insert(str, pos);
} catch (UnsupportedFlavorException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
});
menuIt8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null,"功能简单,绝对原创 ");
}
});
return pane;
}
JTextArea testArea;
private JScrollPane createAreaPane() {
JScrollPane pane = new JScrollPane();
pane.setBorder(new TitledBorder("编辑区域"));
testArea = new JTextArea();
testArea.setFont(new Font("宋体", Font.BOLD, ));
testArea.setLineWrap(true);
pane.getViewport().add(testArea);
return pane;
}
public static void main(String[] args) {
TestDemo td = new TestDemo();
td.setVisible(true);
}
}
你好,可以麻烦你帮我写个实现下图功能的java源码吗,谢谢(ps:我的财富值是零,实在抱歉...)
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/
***
* @author kaifang
* @date 年月日下午5::
*/
public class TestGUI {
private static JTextField textField;
private static JTextField textField_1;
public static void main(String[] args) {
JFrame f = new JFrame("A JFrame");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(, );
f.setLocation(, );
f.getContentPane().setLayout(null);
JLabel lblNewLabel = new JLabel("\uD3\uD");
lblNewLabel.setBounds(, , , );
f.getContentPane().add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("\u5E\u9F");
lblNewLabel_1.setBounds(, , , );
f.getContentPane().add(lblNewLabel_1);
textField = new JTextField();
textField.setBounds(, , , );
f.getContentPane().add(textField);
textField.setColumns();
textField_1 = new JTextField();
textField_1.setBounds(, , , );
f.getContentPane().add(textField_1);
textField_1.setColumns();
JLabel lblNewLabel_2 = new JLabel("\u\uB");
lblNewLabel_2.setBounds(, , , );
f.getContentPane().add(lblNewLabel_2);
JRadioButton rdbtnN = new JRadioButton("\u");
rdbtnN.setBounds(, , , );
f.getContentPane().add(rdbtnN);
JRadioButton radioButton = new JRadioButton("\u");
radioButton.setBounds(, , , );
f.getContentPane().add(radioButton);
ButtonGroup bg = new ButtonGroup();
bg.add(rdbtnN);
bg.add(radioButton);
JLabel label = new JLabel("\uC5\uF");
label.setBounds(, , , );
f.getContentPane().add(label);
JCheckBox chckbxJava = new JCheckBox("Java");
chckbxJava.setBounds(, , , );
f.getContentPane().add(chckbxJava);
JCheckBox chckbxC = new JCheckBox("C");
chckbxC.setBounds(, , , );
f.getContentPane().add(chckbxC);
JLabel label_1 = new JLabel("\uEA\u\u4ECB\u7ECD");
label_1.setBounds(, , , );
f.getContentPane().add(label_1);
JScrollPane scroll = new JScrollPane();
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll.setBounds(, , , );
f.getContentPane().add(scroll);
JTextArea textArea = new JTextArea();
scroll.setViewportView(textArea);
JButton btnNewButton = new JButton("\uE\u5B9A");
btnNewButton.setBounds(, , , );
f.getContentPane().add(btnNewButton);
JButton btnNewButton_1 = new JButton("\uD6\u6D");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
btnNewButton_1.setBounds(, , , );
f.getContentPane().add(btnNewButton_1);
JLabel lblNewLabel_3 = new JLabel("");
lblNewLabel_3.setIcon(new ImageIcon("C:\\Users\\Administrator\\Pictures\\_.jpg"));
lblNewLabel_3.setBounds(, , , );
f.getContentPane().add(lblNewLabel_3);
f.setVisible(true);
}
}