package tuxingjiemian;
import javaxswing;
import javaxswingevent;
import javaawt;
import javaawtevent;
import javaioFile;
import javaioPrintStream;
public class jishiben extends JFrame {
JPanel jp=new JPanel();
JFrame find_replace=new JFrame();
JMenu file=new JMenu("文件");
JMenu edit=new JMenu("编辑");
JMenu help=new JMenu("帮助");
JMenuBar menubar=new JMenuBar();
JTextArea aa=new JTextArea();
class Open implements ActionListener {
public void actionPerformed(ActionEvent e) {
JFileChooser jf= new JFileChooser();
jfshowOpenDialog(jishibenthis);
try {
PrintStream p=new PrintStream(jfgetSelectedFile()getPath());
} catch (Exception e2) {
}
}
}
class Save implements ActionListener {
public void actionPerformed(ActionEvent e) {
JFileChooser jf= new JFileChooser();
jfshowSaveDialog(jishibenthis);
try {
PrintStream p=new PrintStream(jfgetSelectedFile()getPath());
} catch (Exception e2) {
}
}
}
public jishiben(){
thissetTitle("记事本");
thissetSize(500, 500);
thissetLayout(new BorderLayout());
JMenuItem open=new JMenuItem("打开");
openaddActionListener(new Open());
JMenuItem save=new JMenuItem("保存");
saveaddActionListener(new Save());
JMenuItem exit=new JMenuItem("退出");
exitaddActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Systemexit(0);
}
});
fileadd(open);
fileadd(save);
fileaddSeparator();
fileadd(exit);
menubaradd(file);
thisadd(new JScrollPane(aa),BorderLayoutCENTER);
JMenuItem copy=new JMenuItem("复制");
JMenuItem past=new JMenuItem("粘贴");
JMenuItem delete=new JMenuItem("删除");
JMenuItem find=new JMenuItem("查找");
JMenuItem replace=new JMenuItem("替换");
copyaddActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jishibenthisaacopy();
}
});
pastaddActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jishibenthisaapaste();
}
});
deleteaddActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jishibenthisaareplaceSelection(null);
}
});
editadd(copy);
editadd(past);
editadd(delete);
editadd(find);
editadd(replace);
menubaradd(edit);
helpadd(new JMenuItem("帮助"));
menubaradd(help);
thisadd(menubar,BorderLayoutNORTH);
thissetVisible(true);
thissetDefaultCloseOperation(thisEXIT_ON_CLOSE);
}
public static void main(String[] args) {
new jishiben();
}
};
/////////////////////////
import javautil;
public class StudentTest {
int avPass = 90;
int pePass = 96;
int alPass = 150;
public static void main(String[] args) {
StudentTest st = new StudentTest();
Student s1 = new Student("tommy", 85, 96);
Student s2 = new Student("jimmy", 96, 68);
Student s3 = new Student("cherry", 96, 50);
stcheckPass(s1);
stcheckPass(s2);
stcheckPass(s3);
}
public void checkPass(Student s) {
if(sgetAverage() >= thisavPass) {
Systemoutprintln(sgetName() + "达到了录取平均线" + thisavPass + "分,被录取。");
} else if (sgetPeMark() >= thispePass && sgetTotal() >= thisalPass){
Systemoutprintln(sgetName() + "达到了体育录取分数线" + thispePass +
"分, 且综合达到了" + thisalPass + "分,被录取");
} else {
Systemoutprintln(sgetName() + "未达到录取要求!");
}
}
}
class Student{
private int peMark;
private int otherMark;
private String name;
public Student(){}
public Student(String na, int pe, int ot){
thispeMark = pe;
thisotherMark = ot;
thisname = na;
}
public String getName(){
return name;
}
public int getAverage(){
return (peMark + otherMark) / 2;
}
public int getPeMark(){
return peMark;
}
public int getTotal(){
return peMark + otherMark;
}
public String toString(){
return "姓名: " + name + "\n体育成绩:" + peMark
+ "\n其他成绩:" + otherMark + "\n平均成绩:" + getAverage();
}
}
////////////output:
tommy达到了录取平均线90分,被录取。
jimmy达到了体育录取分数线96分, 且综合达到了150分,被录取
cherry未达到录取要求!
import javaawt;
import javaapplet;
import javaawtevent;
public class L07_D extends Applet implements ActionListener{
public void init() {
Button one;
Button two;
one = new Button("Button one");
two = new Button("Button two");
add(one);add(two);
oneaddActionListener(this);
twoaddActionListener(this);
}
public void actionPerformed(ActionEvent e) {
showStatus("One of my buttons was clicked");
}
}
以上就是关于java编写一个记事本小程序,接着下面的代码写,求大神解救!实现新建,保存,打开功能就行!全部的内容,包括:java编写一个记事本小程序,接着下面的代码写,求大神解救!实现新建,保存,打开功能就行!、JAVA设计个小程序~、Java中Applet小程序的编写等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)