大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

发帖java的代码 java发帖回帖代码

求编写一个超级简单的Java的程序源代码

import java.awt.*;

成都创新互联专注于麒麟企业网站建设,响应式网站建设,商城网站开发。麒麟网站建设公司,为麒麟等地区提供建站服务。全流程定制网站设计,专业设计,全程项目跟踪,成都创新互联专业和态度为您提供的服务

import java.awt.event.*;

import javax.swing.*;

class ConstructFrame extends JFrame

{

private static final long serialVersionUID = 1L;

String value1="",result,value2="";

int flag=0,fix=0,sum=1;

Boolean happy;

JTextField text=new JTextField(30);

int flagsum=0;

Container c=getContentPane();

JButton buttonx;

ConstructFrame()

{ super("计算器");

c.setLayout(null);

c.setBackground(Color.blue);

this.setSize(400, 400);

c.add(text);

text.setHorizontalAlignment(JTextField.RIGHT);

final JButton buttonx=new JButton("BackSpace");

c.add(buttonx);

buttonx.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

int count=0;

String temp;

if(flag==0)

{

count=value1.length();

if(count!=1)

temp=value1.substring(0, count-1);

else

temp="0";

value1=temp;

}

else

{

count=value2.length();

if(count!=1)

temp=value2.substring(0, count-1);

else

temp="0";

value2=temp;

}

text.setText(temp);

}

});

final JButton buttony=new JButton("CE");

c.add(buttony);

buttony.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

value1="";

value2="";

flag=0;

text.setText("0");

}

});

final JButton button1=new JButton("1");

c.add(button1);

button1.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+1;

temp=value1;

}

else

{

value2=value2+1;

temp=value2;

}

text.setText(temp);

}

});

final JButton button2=new JButton(" 2 ");

c.add(button2);

button2.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+2;

temp=value1;

}

else

{

value2=value2+2;

temp=value2;

}

text.setText(temp);

}

});

final JButton button3=new JButton("3");

c.add(button3);

button3.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+3;

temp=value1;

}

else

{

value2=value2+3;

temp=value2;

}

text.setText(temp);

}

});

final JButton button4=new JButton("4");

c.add(button4);

button4.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+4;

temp=value1;

}

else

{

value2=value2+4;

temp=value2;

}

text.setText(temp);

}

});

final JButton button5=new JButton("5");

c.add(button5);

button5.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+5;

temp=value1;

}

else

{

value2=value2+5;

temp=value2;

}

text.setText(temp);

}

});

final JButton button6=new JButton("6");

c.add(button6);

button6.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+6;

temp=value1;

}

else

{

value2=value2+6;

temp=value2;

}

text.setText(temp);

}

});

final JButton button7=new JButton("7");

c.add(button7);

button7.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+7;

temp=value1;

}

else

{

value2=value2+7;

temp=value2;

}

text.setText(temp);

}

});

final JButton button8=new JButton("8");

c.add(button8);

button8.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+8;

temp=value1;

}

else

{

value2=value2+8;

temp=value2;

}

text.setText(temp);

}

});

final JButton button9=new JButton("9");

c.add(button9);

button9.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+9;

temp=value1;

}

else

{

value2=value2+9;

temp=value2;

}

text.setText(temp);

}

});

final JButton button0=new JButton("0");

c.add(button0);

button0.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+0;

temp=value1;

}

else

{

value2=value2+0;

temp=value2;

}

text.setText(temp);

}

});

final JButton buttonadd=new JButton(" + ");

c.add(buttonadd);

buttonadd.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

flag=1;

fix=1;

flagsum=0;

}

});

final JButton buttonsubtract=new JButton(" - ");

c.add(buttonsubtract);

buttonsubtract.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

flag=1;

fix=2;

flagsum=0;

}

});

final JButton buttoncheng=new JButton(" * ");

c.add(buttoncheng);

buttoncheng.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

flag=1;

fix=3;

flagsum=0;

}

});

final JButton buttonchu=new JButton(" / ");

c.add(buttonchu);

buttonchu.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

flag=1;

flagsum=0;

fix=4;

}

});

final JButton buttonequal=new JButton(" = ");

c.add(buttonequal);

buttonequal.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

double temp1,temp2;

double temp=0;

flagsum=0;

temp1=Double.parseDouble(value1);

temp2=Double.parseDouble(value2);

flag=0;

switch(fix)

{

case 1: temp=temp1+temp2;break;

case 2: temp=temp1-temp2;break;

case 3: temp=temp1*temp2;break;

case 4: temp=temp1/temp2;break;

}

result=Double.valueOf(temp).toString();

value1=result;

value2="";

flag=1;

text.setText(result);

}

});

final JButton buttonpoint=new JButton(".");

c.add(buttonpoint);

buttonpoint.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{ if(flagsum==0)

{

String temp;

if(flag==0 )

{

value1=value1+".";

temp=value1;

}

else

{

value2=value2+".";

temp=value2;

}

flagsum=1;

text.setText(temp);

}

}

});

JButton buttonz=new JButton("Start");

c.add(buttonz);

buttonz.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{ if(sum%2==1)

{

happy=true;

text.setText("0.");

flag=0;

}

else

{

happy=false;

value1="";

value2="";

text.setText("");

}

text.setEnabled(happy);

button1.setEnabled(happy);

button2.setEnabled(happy);

button3.setEnabled(happy);

button4.setEnabled(happy);

button5.setEnabled(happy);

button6.setEnabled(happy);

button7.setEnabled(happy);

button8.setEnabled(happy);

button9.setEnabled(happy);

button0.setEnabled(happy);

buttonx.setEnabled(happy);

buttony.setEnabled(happy);

buttonadd.setEnabled(happy);

buttonsubtract.setEnabled(happy);

buttonpoint.setEnabled(happy);

buttonequal.setEnabled(happy);

buttoncheng.setEnabled(happy);

buttonchu.setEnabled(happy);

sum++;

}

});

button1.setEnabled(false);

button2.setEnabled(false);

button3.setEnabled(false);

button4.setEnabled(false);

button5.setEnabled(false);

button6.setEnabled(false);

button7.setEnabled(false);

button8.setEnabled(false);

button9.setEnabled(false);

button0.setEnabled(false);

buttonx.setEnabled(false);

buttony.setEnabled(false);

buttonadd.setEnabled(false);

buttonsubtract.setEnabled(false);

buttonpoint.setEnabled(false);

buttonequal.setEnabled(false);

buttoncheng.setEnabled(false);

buttonchu.setEnabled(false);

text.setEnabled(false);

text.setBounds(20, 20, 200, 40);

buttonx.setBounds(20, 60,100, 40);

buttony.setBounds(140, 60,100, 40);

buttonz.setBounds(260, 60,80, 40);

button1.setBounds(20, 120,60, 40);

button2.setBounds(100, 120,60, 40);

button3.setBounds(180, 120,60, 40);

buttonadd.setBounds(260, 120,60, 40);

button4.setBounds(20, 180,60, 40);

button5.setBounds(100, 180,60, 40);

button6.setBounds(180, 180,60, 40);

buttonsubtract.setBounds(260, 180,60, 40);

button7.setBounds(20, 240,60, 40);

button8.setBounds(100, 240,60, 40);

button9.setBounds(180, 240,60, 40);

buttoncheng.setBounds(260,240,60,40);

button0.setBounds(20, 300,60, 40);

buttonpoint.setBounds(100, 300, 60, 40);

buttonequal.setBounds(180,300,60, 40);

buttonchu.setBounds(260, 300,60, 40);

setVisible(true);

}

class MYMouseEvent extends MouseAdapter

{

public void mousePressed(MouseEvent e)

{

value1=e.toString();

text.setText(value1);

}

}

}

class Calutator

{

public static void main(String[] args)

{

new ConstructFrame();

}

}

你自己慢慢的看吧!

求一个50行左右的JAVA代码,最好每行带注释,谢谢啦

/*这个相当详细了.

程序也不算太难.而且给老师看的时候效果比较好.因为有图形化界面,又实现一个比较实用的功能.老师会比较高兴的.

建立一个文件名为Change.java就可以编译了*/

/*

* 这个程序实现输入身高算出标准体重,输入体重,算出身高的功能

*/

import java.awt.*; //导入相关类包,这才样使用相应awt图形界面的类

import java.awt.event.*;//同上

public class Change extends Frame { //定义一个类Change, 父类是Frame(图形界面的)

Button b = new Button("互查"); //创建一个按钮的对象b,显示为"互查"

Label l1 = new Label("身高(cm)");//创建一个lable.显示身高

Label l2 = new Label("体重(kg)");//创建一个lable 显示体重

double heigth, weigth; //定义变量

double x, y; //定义变量

TextField tf1 = new TextField(null, 10);//添加Text框

TextField tf2 = new TextField(null, 10);//添加Text框

public Change() {//类的构造函数,完成初始化

super("互查表");//创建窗口,标题为互查表

setLayout(new FlowLayout(FlowLayout.LEFT));//设置布局

add(l1);//把lable 身高放到window里

add(tf1);//把Text 框 放到窗口上

add(l2); //把lable 体重放到window里

add(tf2);//Test放到窗口里

add(b);//把button放到窗口上

pack();//自动放到窗口里排列上边的组件

setVisible(true);//可以让用户看到窗口

addWindowListener(new WindowAdapter() {//如果按 X, 关闭窗口

public void windowClosing(WindowEvent e) {

System.exit(0);

}

});

b.addActionListener(new ButtonListener());//添加button监听函数

}

class ButtonListener implements ActionListener {//实现click button时功能操作

public void actionPerformed(ActionEvent e) {//当click调用

if (tf1.getText()!=null) {//检查tf1 test 是否为空

try {//取异常

x = Double.parseDouble(tf1.getText());//字符转为double型

weigth = (x - 100) * 0.9;//算重量

tf2.setText("" + weigth);//显示重量

} catch (NumberFormatException ex) {

tf1.setText("");//如果输入不是数字,设为空

}

}

if (tf1.getText().equals("")==true){//tf1是否为空

y = Double.parseDouble(tf2.getText());//把tf2里的文本转为double 型 的

heigth = y / 0.9 + 100; //算身高根据重量

tf1.setText("" + heigth);}//显示身高

}

}

public static void main(String[] args) {//主函数,程序入口

new Change(); //建立类Change的对象,并调用他的构造函数Change().显示窗口

}

}

java写的代码

package com.ailk.client;

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.FileReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.OutputStreamWriter;

import java.io.Reader;

public class FileTest {

public static void main(String[] args) {

// TODO Auto-generated method stub

String filePath = "d:/text1.txt";

readFile(filePath,99);

}

public static void readFile(String fileName, int grede){

File file = new File(fileName);

BufferedReader reader = null;

BufferedWriter bw = null;       

try {

System.out.println("以行为单位读取文件内容,一次读一整行:");

reader = new BufferedReader(new FileReader(file));

bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("d:/test2.txt")), "UTF-8"));

String tempString = null;

int line = 1;

// 一次读入一行,直到读入null为文件结束

while ((tempString = reader.readLine()) != null) {

// 显示行号

System.out.println("line " + line + ": " + tempString);

if(line==4){

//此处为你自己设定的文件中代表成绩的位置

tempString = tempString.substring(0, 37)+grede+tempString.substring(39, tempString.length());

System.out.println("line " + line + ": " + tempString);

}

bw.write(tempString);

bw.newLine();

line++;

}

reader.close();

} catch (IOException e) {

e.printStackTrace();

} finally {

if (reader != null) {

try {

reader.close();

} catch (IOException e1) {

}

}

if (bw != null) {

try {

bw.close();

} catch (IOException e1) {

}

}

}

}

}

需要自己d盘建立text1.txt,内容你自己根据要求,代码中写死的37和39为你要修改的成绩的位置。

效果图如下,中午给你写的记得采纳

帮忙写个java的代码,感激不尽啊

import java.awt.BorderLayout;

import java.awt.Container;

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.InputEvent;

import java.awt.event.KeyAdapter;

import java.awt.event.KeyEvent;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import javax.swing.BorderFactory;

import javax.swing.JFileChooser;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JOptionPane;

import javax.swing.JPopupMenu;

import javax.swing.JScrollPane;

import javax.swing.JTextArea;

import javax.swing.KeyStroke;

import javax.swing.ScrollPaneConstants;

import javax.swing.SwingConstants;

public class JNotePadUI extends JFrame {

private JMenuItem menuOpen;

private JMenuItem menuSave;

private JMenuItem menuSaveAs;

private JMenuItem menuClose;

private JMenu editMenu;

private JMenuItem menuCut;

private JMenuItem menuCopy;

private JMenuItem menuPaste;

private JMenuItem menuAbout;

private JTextArea textArea;

private JLabel stateBar;

private JFileChooser fileChooser;

private JPopupMenu popUpMenu;

public JNotePadUI() {

super("新建文本文件");

setUpUIComponent();

setUpEventListener();

setVisible(true);

}

private void setUpUIComponent() {

setSize(640, 480);

// 菜单栏

JMenuBar menuBar = new JMenuBar();

// 设置「文件」菜单

JMenu fileMenu = new JMenu("文件");

menuOpen = new JMenuItem("打开");

// 快捷键设置

menuOpen.setAccelerator(

KeyStroke.getKeyStroke(

KeyEvent.VK_O,

InputEvent.CTRL_MASK));

menuSave = new JMenuItem("保存");

menuSave.setAccelerator(

KeyStroke.getKeyStroke(

KeyEvent.VK_S,

InputEvent.CTRL_MASK));

menuSaveAs = new JMenuItem("另存为");

menuClose = new JMenuItem("关闭");

menuClose.setAccelerator(

KeyStroke.getKeyStroke(

KeyEvent.VK_Q,

InputEvent.CTRL_MASK));

fileMenu.add(menuOpen);

fileMenu.addSeparator(); // 分隔线

fileMenu.add(menuSave);

fileMenu.add(menuSaveAs);

fileMenu.addSeparator(); // 分隔线

fileMenu.add(menuClose);

// 设置「编辑」菜单

JMenu editMenu = new JMenu("编辑");

menuCut = new JMenuItem("剪切");

menuCut.setAccelerator(

KeyStroke.getKeyStroke(KeyEvent.VK_X,

InputEvent.CTRL_MASK));

menuCopy = new JMenuItem("复制");

menuCopy.setAccelerator(

KeyStroke.getKeyStroke(KeyEvent.VK_C,

InputEvent.CTRL_MASK));

menuPaste = new JMenuItem("粘贴");

menuPaste.setAccelerator(

KeyStroke.getKeyStroke(KeyEvent.VK_V,

InputEvent.CTRL_MASK));

editMenu.add(menuCut);

editMenu.add(menuCopy);

editMenu.add(menuPaste);

// 设置「关于」菜单

JMenu aboutMenu = new JMenu("关于");

menuAbout = new JMenuItem("关于JNotePad");

aboutMenu.add(menuAbout);

menuBar.add(fileMenu);

menuBar.add(editMenu);

menuBar.add(aboutMenu);

setJMenuBar(menuBar);

// 文字编辑区域

textArea = new JTextArea();

textArea.setFont(new Font("宋体", Font.PLAIN, 16));

textArea.setLineWrap(true);

JScrollPane panel = new JScrollPane(textArea,

ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,

ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

Container contentPane = getContentPane();

contentPane.add(panel, BorderLayout.CENTER);

// 状态栏

stateBar = new JLabel("未修改");

stateBar.setHorizontalAlignment(SwingConstants.LEFT);

stateBar.setBorder(

BorderFactory.createEtchedBorder());

contentPane.add(stateBar, BorderLayout.SOUTH);

popUpMenu = editMenu.getPopupMenu();

fileChooser = new JFileChooser();

}

private void setUpEventListener() {

// 按下窗口关闭钮事件处理

addWindowListener(

new WindowAdapter() {

public void windowClosing(WindowEvent e) {

closeFile();

}

}

);

// 菜单 - 打开

menuOpen.addActionListener(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

openFile();

}

}

);

// 菜单 - 保存

menuSave.addActionListener(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

saveFile();

}

}

);

// 菜单 - 另存为

menuSaveAs.addActionListener(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

saveFileAs();

}

}

);

// 菜单 - 关闭文件

menuClose.addActionListener(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

closeFile();

}

}

);

// 菜单 - 剪切

menuCut.addActionListener(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

cut();

}

}

);

// 菜单 - 复制

menuCopy.addActionListener(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

copy();

}

}

);

// 菜单 - 粘贴

menuPaste.addActionListener(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

paste();

}

}

);

// 菜单 - 关于

menuAbout.addActionListener(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

// 显示对话框

JOptionPane.showOptionDialog(null,

"程序名称:\n JNotePad \n" +

"程序设计:\n \n" +

"简介:\n 一个简单的文字编辑器\n" +

" 可作为验收Java的实现对象\n" +

" 欢迎网友下载研究交流\n\n" +

" /",

"关于JNotePad",

JOptionPane.DEFAULT_OPTION,

JOptionPane.INFORMATION_MESSAGE,

null, null, null);

}

}

);

// 编辑区键盘事件

textArea.addKeyListener(

new KeyAdapter() {

public void keyTyped(KeyEvent e) {

processTextArea();

}

}

);

// 编辑区鼠标事件

textArea.addMouseListener(

new MouseAdapter() {

public void mouseReleased(MouseEvent e) {

if(e.getButton() == MouseEvent.BUTTON3)

popUpMenu.show(editMenu, e.getX(), e.getY());

}

public void mouseClicked(MouseEvent e) {

if(e.getButton() == MouseEvent.BUTTON1)

popUpMenu.setVisible(false);

}

}

);

}

private void openFile() {

if(isCurrentFileSaved()) { // 文件是否为保存状态

open(); // 打开

}

else {

// 显示对话框

int option = JOptionPane.showConfirmDialog(

null, "文件已修改,是否保存?",

"保存文件?", JOptionPane.YES_NO_OPTION,

JOptionPane.WARNING_MESSAGE, null);

switch(option) {

// 确认文件保存

case JOptionPane.YES_OPTION:

saveFile(); // 保存文件

break;

// 放弃文件保存

case JOptionPane.NO_OPTION:

open();

break;

}

}

}

private boolean isCurrentFileSaved() {

if(stateBar.getText().equals("未修改")) {

return false;

}

else {

return true;

}

}

private void open() {

// fileChooser 是 JFileChooser 的实例

// 显示文件选取的对话框

int option = fileChooser.showDialog(null, null);

// 使用者按下确认键

if(option == JFileChooser.APPROVE_OPTION) {

try {

// 开启选取的文件

BufferedReader buf =

new BufferedReader(

new FileReader(

fileChooser.getSelectedFile()));

// 设定文件标题

setTitle(fileChooser.getSelectedFile().toString());

// 清除前一次文件

textArea.setText("");

// 设定状态栏

stateBar.setText("未修改");

// 取得系统相依的换行字符

String lineSeparator = System.getProperty("line.separator");

// 读取文件并附加至文字编辑区

String text;

while((text = buf.readLine()) != null) {

textArea.append(text);

textArea.append(lineSeparator);

}

buf.close();

}

catch(IOException e) {

JOptionPane.showMessageDialog(null, e.toString(),

"开启文件失败", JOptionPane.ERROR_MESSAGE);

}

}

}

private void saveFile() {

// 从标题栏取得文件名称

File file = new File(getTitle());

// 若指定的文件不存在

if(!file.exists()) {

// 执行另存为

saveFileAs();

}

else {

try {

// 开启指定的文件

BufferedWriter buf =

new BufferedWriter(

new FileWriter(file));

// 将文字编辑区的文字写入文件

buf.write(textArea.getText());

buf.close();

// 设定状态栏为未修改

stateBar.setText("未修改");

}

catch(IOException e) {

JOptionPane.showMessageDialog(null, e.toString(),

"写入文件失败", JOptionPane.ERROR_MESSAGE);

}

}

}

private void saveFileAs() {

// 显示文件对话框

int option = fileChooser.showSaveDialog(null);

// 如果确认选取文件

if(option == JFileChooser.APPROVE_OPTION) {

// 取得选择的文件

File file = fileChooser.getSelectedFile();

// 在标题栏上设定文件名称

setTitle(file.toString());

try {

// 建立文件

file.createNewFile();

// 进行文件保存

saveFile();

}

catch(IOException e) {

JOptionPane.showMessageDialog(null, e.toString(),

"无法建立新文件", JOptionPane.ERROR_MESSAGE);

}

}

}

private void closeFile() {

// 是否已保存文件

if(isCurrentFileSaved()) {

// 释放窗口资源,而后关闭程序

dispose();

}

else {

int option = JOptionPane.showConfirmDialog(

null, "文件已修改,是否保存?",

"保存文件?", JOptionPane.YES_NO_OPTION,

JOptionPane.WARNING_MESSAGE, null);

switch(option) {

case JOptionPane.YES_OPTION:

saveFile();

break;

case JOptionPane.NO_OPTION:

dispose();

}

}

}

private void cut() {

textArea.cut();

stateBar.setText("已修改");

popUpMenu.setVisible(false);

}

private void copy() {

textArea.copy();

popUpMenu.setVisible(false);

}

private void paste() {

textArea.paste();

stateBar.setText("已修改");

popUpMenu.setVisible(false);

}

private void processTextArea() {

stateBar.setText("已修改");

}

public static void main(String[] args) {

new JNotePadUI();

}

}

java中的代码

1.b应该是加''(单引号)

2.加了单引号也是错误的,因为setCharAt实际上是已经把s修改了,然后返回void,自然不能把void赋值给t啊,所以,改成下面的就可以了

StringBuffer s=new StringBuffer("Java Applet");

System.out.println("s="+s);

s.setCharAt(3,'b');

System.out.println(s);


网页标题:发帖java的代码 java发帖回帖代码
标题来源:http://dzwzjz.com/article/hhepsg.html
在线咨询
服务热线
服务热线:028-86922220
TOP