求助:JAVA小程序

求助:JAVA小程序,第1张

分类: 电脑/网络 >> 程序设计 >> 其他编程语言

问题描述:

我们修的汇编语言是JAVA,怎奈自己学术不精现在此象高手请教小程序是期末做课程设计用的题目有日历记事本,学籍管理系统,计算器,画图程序其他的也可以现需要两个程序,谢谢大家!

解析:

import javaio;

import javautilCalendar;

import javaawt;

import javaawtevent;

import javaxswing;

public class NoteBook extends JFrame implements ActionListener,ItemListener,WindowListener,MouseListener{

Container c = thisgetContentPane();

JMenuBar jmb = new JMenuBar();

JColorChooser jcc = new JColorChooser();

JMenu jm1 = new JMenu("文件(F)");

JMenu jm2 = new JMenu("编辑(E)");

JMenu jm3 = new JMenu("格式(O)");

JMenu jm4 = new JMenu("查看(V)");

JMenu jm5 = new JMenu("帮助(H)");

JMenuItem jmi1 = new JMenuItem("新建(N)");

JMenuItem jmi2 = new JMenuItem("打开(O)");

JMenuItem jmi3 = new JMenuItem("保存(S)");

JMenuItem jmi4 = new JMenuItem("退出(X)");

JMenuItem jmi5 = new JMenuItem("撤消(U)");

JMenuItem jmi6 = new JMenuItem("复制(C)");

JMenuItem jmi7 = new JMenuItem("粘贴(P)");

JMenuItem jmi8 = new JMenuItem("剪切(T)");

JMenuItem jmi12 = new JMenuItem("日期和时间");

JMenuItem jmi9 = new JMenuItem("字体(E)");

JCheckBoxMenuItem jcbmi = new JCheckBoxMenuItem("自动换行(W)");

JMenuItem jmi10 = new JMenuItem("删除(S)");

JMenuItem jmi11 = new JMenuItem("背景颜色(H)");

JTextArea jta = new JTextArea(15,15);

JScrollPane jsp = new JScrollPane(jta);

PupolMenu pm = new Pupolmenu();

NoteBook(){

thisaddWindowListener(this);

csetLayout(new BorderLayout());

cadd(jmb,BorderLayoutNORTH);

thissetTitle("新建 文本文档");

jmbadd(jm1);

jm1setMnemonic('f');

jm1addActionListener(this);

jmbadd(jm2);

jm2setMnemonic('e');

jmbadd(jm3);

jm3setMnemonic('o');

jmbadd(jm4);

jm4setMnemonic('v');

jmbadd(jm5);

jm5setMnemonic('h');

jm1add(jmi1);

jmi1addActionListener(this);

jmi1setAccelerator(KeyStrokegetKeyStroke('N',EventCTRL_MASK,false));

jm1addSeparator();

jm1add(jmi2);

jmi2setAccelerator(KeyStrokegetKeyStroke('O',EventCTRL_MASK,false));

jmi2addActionListener(this);

jm1addSeparator();

jm1add(jmi3);

jmi3setAccelerator(KeyStrokegetKeyStroke('S',EventCTRL_MASK,false));

jmi3addActionListener(this);

jm1addSeparator();

jm1add(jmi4);

jmi1setMnemonic('n');

jmi2setMnemonic('o');

jmi3setMnemonic('s');

jmi4setMnemonic('x');

jmi4addActionListener(this);

jm2add(jmi5);

jm2addSeparator();

jm2add(jmi6);

jm2addSeparator();

jm2add(jmi7);

jm2addSeparator();

jm2add(jmi8);

jm2add(jmi12);

jmi12addActionListener(this);

jm3add(jcbmi);

jcbmiaddItemListener(this);

jm3addSeparator();

jm3add(jmi9);

jm4add(jmi10);

jmi10addActionListener(this);

jm5add(jmi11);

jmi11addActionListener(this);

cadd(jsp);

thissetDefaultCloseOperation(JFrameDISPOSE_ON_CLOSE);

thissetSize(500,500);

thissetVisible(true);

}

public void actionPerformed(ActionEvent e){

if(egetSource()==jmi1){

jtasetText("");

thissetTitle("无标题 - 记事本");

}

if(egetSource()==jmi2){

File f1;

JFileChooser jfc1 = new JFileChooser();

int num1 = jfc1showOpenDialog(this);

if(num1==JFileChooserAPPROVE_OPTION){

try{

f1 = jfc1getSelectedFile();

thissetTitle(f1getName());

FileReader fr = new FileReader(f1);

BufferedReader br = new BufferedReader(fr);

String str;

while((str = brreadLine())!=null){

jtasetText(str);

}

frclose();

brclose();

}catch(FileNotFoundException e1){

e1printStackTrace();

}catch(IOException e2){

e2printStackTrace();

}

}

}

if(egetSource()==jmi3){

File f2 = null;

JFileChooser jfc2 = new JFileChooser();

int num2 = jfc2showSaveDialog(this);

if(num2==JFileChooserAPPROVE_OPTION){

f2=jfc2getSelectedFile();

thissetTitle(f2getName());

try{

FileWriter fw = new FileWriter(f2);

BufferedWriter bw = new BufferedWriter(fw);

bwwrite(jtagetText());

bwclose();

fwclose();

}catch(IOException e2){

e2printStackTrace();

}

}

}

if(egetSource()==jmi4){

int a = JOptionPaneshowConfirmDialog(this,"文件已被改变,是否要保存?","提示",JOptionPaneYES_NO_CANCEL_OPTION);

if(a==1){

thisdispose();

}else if(a==0){

File f2 = null;

JFileChooser jfc2 = new JFileChooser();

int num2 = jfc2showSaveDialog(this);

if(num2==JFileChooserAPPROVE_OPTION){

f2=jfc2getSelectedFile();

thissetTitle(f2getName());

try{

FileWriter fw = new FileWriter(f2);

BufferedWriter bw = new BufferedWriter(fw);

bwwrite(jtagetText());

bwclose();

fwclose();

}catch(IOException e2){

e2printStackTrace();

}

thisdispose();

}

}

}

if(egetSource()==jmi12){

Calendar c1 =CalendargetInstance();

int y = c1get(CalendarYEAR);

int m = c1get(CalendarMONTH);

int d = c1get(CalendarDATE);

int h = c1get(CalendarHOUR);

int m1 = c1get(CalendarMINUTE);

int m2 = m+1;

jtasetText(y+"年"+m2+"月"+d+"日"+h+":"+m1);

}

if(egetSource()==jmi11){

Color ccc = JColorChoosershowDialog(this,"color",ColorBLACK);

jtasetSelectedTextColor(ccc);

jtasetBackground(ccc);

}

if(egetSource()==jmi10){

jtareplaceRange("",jtagetSelectionStart(),jtagetSelectionEnd());

}

}

public void itemStateChanged(ItemEvent e2){

if(e2getItemSelectable()==jcbmi){

jtasetLineWrap(true);

}else

jtasetLineWrap(false);

}

public static void main(String[] args){

new NoteBook();

}

public void windowOpened(WindowEvent arg0) {

}

public void windowClosing(WindowEvent arg0) {

int a = JOptionPaneshowConfirmDialog(this,"文件已被改变,是否要保存?","提示",JOptionPaneYES_NO_CANCEL_OPTION);

if(a==1){

thisdispose();

}else if(a==0){

File f2 = null;

JFileChooser jfc2 = new JFileChooser();

int num2 = jfc2showSaveDialog(this);

if(num2==JFileChooserAPPROVE_OPTION){

f2=jfc2getSelectedFile();

thissetTitle(f2getName());

try{

FileWriter fw = new FileWriter(f2);

BufferedWriter bw = new BufferedWriter(fw);

bwwrite(jtagetText());

bwclose();

fwclose();

}catch(IOException e2){

e2printStackTrace();

}

}

if(a==2){

/

}

}

}

public void windowClosed(WindowEvent arg0) {

}

public void windowIconified(WindowEvent arg0) {

TODO Auto-generated method stub

}

public void windowDeiconified(WindowEvent arg0) {

TODO Auto-generated method stub

}

public void windowActivated(WindowEvent arg0) {

TODO Auto-generated method stub

}

public void windowDeactivated(WindowEvent arg0) {

TODO Auto-generated method stub

}

public void mouseClicked(MouseEvent arg0) {

TODO Auto-generated method stub

}

public void mousePressed(MouseEvent arg0) {

TODO Auto-generated method stub

}

public void mouseReleased(MouseEvent arg0) {

TODO Auto-generated method stub

}

public void mouseEntered(MouseEvent arg0) {

TODO Auto-generated method stub

}

public void mouseExited(MouseEvent arg0) {

TODO Auto-generated method stub

}

}

关键是你要说清楚你想找哪类的啊,有很多类,游戏类,网络类,web类的,还有手机上的J2ME,你搞清楚后在来问吧,这孩子,怪可怜的,如果你要applets的话,java安装目录下的DEMO中就有,你可以自己琢磨

public class Test {

public static void main(String[] args)throws WeightException{

WeigthCheck wc = new WeigthCheck();

float f = FloatparseFloat(args[0]);

if(wccheck(f)){

Systemoutprintln("您可以参加游戏。");

}else{

throw new WeightException("你不能参加游戏");

}

}

}

public class WeigthCheck{

public boolean check(float f){

boolean flag = false;

if(40 < f && f < 100){

flag = true;

}

return flag;

}

}

public class WeightException extends Exception{

public WeightException(){

super();

}

public WeightException(String s){

super(s);

}

}

int top = 0, sa[];

这句话是有问题的 int类型定义了2个量 一个是top 一个是sa[]

然而sa[] 却应该是一个int[]类型的 可以这个改下

int top = 0;

int[] sa = new int[10];

下边程序的qe也一样改过来

此外 你的程序中还要数组越界的问题 好好看看把

以上就是关于求助:JAVA小程序全部的内容,包括:求助:JAVA小程序、想找一些java小程序,谁能帮帮我啊、java小程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10108525.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存