java记事本的基本框架

用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,
"程序名称:
JNotePad
" +
"程序设计:

" +
"简介:
一个简单的文字编辑器
" +
" 可作为验收Java的实现对象
" +
" 欢迎网友下载研究交流

" +
" /",
"关于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();
}
}

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class MyText extends JFrame {
// 用来放JTextArea的面板
private JScrollPane myJScrollPane;
// 声明JFrame中的JTextArea和JMenuBar
private JTextArea myTextArea;
private JMenuBar myMenuBar;
// 声明JMenuBar中的JMenu
private JMenu myMenuFile;
private JMenu myMenuEdit;
private JMenu myMenuForm;
private JMenu myMenuCheck;
private JMenu myMenuHelp;
// 声明myMenuFile的JMenuItem
private JMenuItem myMenuItemNew;
private JMenuItem myMenuItemOpen;
private JMenuItem myMenuItemSave;
private JMenuItem myMenuItemSaveAs;
private JMenuItem myMenuItemPageSetup;
private JMenuItem myMenuItemPrint;
private JMenuItem myMenuItemExit;

//**************************************
// 需要自己在这里定义其他JMenu的JMenuItem
//**************************************

public MyText() {

// 为myTextArea和myMenuBar分配内存
this.myTextArea = new JTextArea();
this.myMenuBar = new JMenuBar();
//把JTextArea放到JScrollPane中去
this.myJScrollPane = new JScrollPane(this.myTextArea);
// 为JMenu分配内存并命名
this.myMenuFile = new JMenu("文件");
this.myMenuEdit = new JMenu("编辑");
this.myMenuForm = new JMenu("格式");
this.myMenuCheck = new JMenu("查看");
this.myMenuHelp = new JMenu("帮助");
// 为JMenuItem分配内存并命名
this.myMenuItemNew = new JMenuItem("新建");
this.myMenuItemOpen = new JMenuItem("打开");
this.myMenuItemSave = new JMenuItem("保存");
this.myMenuItemSaveAs = new JMenuItem("另存为...");
this.myMenuItemPageSetup = new JMenuItem("页面设置...");
this.myMenuItemPrint = new JMenuItem("打印");
this.myMenuItemExit = new JMenuItem("退出");
// 把JMenuItem添加到JMenu中去
this.myMenuFile.add(this.myMenuItemNew);
this.myMenuFile.add(this.myMenuItemOpen);
this.myMenuFile.add(this.myMenuItemSave);
this.myMenuFile.add(this.myMenuItemSaveAs);
this.myMenuFile.add(this.myMenuItemPageSetup);
this.myMenuFile.add(this.myMenuItemPrint);
this.myMenuFile.add(this.myMenuItemExit);

//****************************************************
// 在这里把自己定义的其他的JMenuItem也添加到相应的JMenu中去
//****************************************************

// 把JMenu添加到JMenuBar中去
this.myMenuBar.add(this.myMenuFile);
this.myMenuBar.add(this.myMenuEdit);
this.myMenuBar.add(this.myMenuForm);
this.myMenuBar.add(this.myMenuCheck);
this.myMenuBar.add(this.myMenuHelp);
// 把JMenuBar和JScrollPane添加到JFrame中去
this.setJMenuBar(this.myMenuBar);
this.add(this.myJScrollPane);

//
// 在这里需要给所有JMenuItem对象加上监听
//

// 设置JFrame属性
this.setTitle("记事本");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setBounds(200, 200, 800, 500);
}

//******************************************************************************
// 这里需要自己写监听来监听JMenuItem的事件,与给JButton添加监听一样,也可以直接在构造函数中给JMenuItem添加内部类监听
//******************************************************************************

public static void main(String[] args) {
new MyText().setVisible(true);
}
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.datatransfer.*;
import java.util.*;
public class NotePad//本实验仅实现:文件(暂时模拟)打开,新建,保存,另存为,转到
{ //具体实现:剪切,复制,粘贴,删除,全选,打印,退出,页面设置,日期时间
//其他待实现
public static void main(String args[])
{

MyWindow my=new MyWindow("我的记事本");

}

}

class MyWindow extends Frame implements ActionListener
{
MyDialog dia1;
FileDialog saver,opener,save_as;
Clipboard clipboard;
MenuBar bar;
Menu menu1,menu2,menu3,menu4,menu5;
MenuItem newmake,open,save,saveas,pageset,print,exit;
MenuItem che,cut,copy,paste,del,search,s_next,replace,trans,save_all,data_time;
MenuItem letter;
MenuItem statusbar;
MenuItem help1,help2;
TextArea tex;
PrintJob p=null;
Graphics g=null;
CheckboxMenuItem auto_newline;
MyWindow(String s)
{
super(s);
dia1=new MyDialog(this,"转到下列行",true);

clipboard=getToolkit().getSystemClipboard();
saver=new FileDialog(this,"保存文件",FileDialog.SAVE);
//saver.setLocation(100,60);
opener=new FileDialog(this,"打开文件",FileDialog.LOAD);
save_as=new FileDialog(this,"另存为",FileDialog.LOAD);

bar=new MenuBar();
Menu menu1=new Menu("文件(F)");
Menu menu2=new Menu("编辑(E)");
Menu menu3=new Menu("格式(O)");
Menu menu4=new Menu("查看(V)");
Menu menu5=new Menu("帮助(H)");

newmake=new MenuItem("新建(N)");
newmake.addActionListener(this);
newmake.setShortcut(new MenuShortcut(KeyEvent.VK_N));
open=new MenuItem("打开(O)");
open.addActionListener(this);
open.setShortcut(new MenuShortcut(KeyEvent.VK_O));
save=new MenuItem("保存(S)");
save.addActionListener(this);
save.setShortcut(new MenuShortcut(KeyEvent.VK_S));
saveas=new MenuItem("另存为(A)");
saveas.addActionListener(this);
pageset=new MenuItem("页面设置(U)...");
pageset.addActionListener(this);
print=new MenuItem("打印(P)...");
print.addActionListener(this);
print.setShortcut(new MenuShortcut(KeyEvent.VK_P));
exit=new MenuItem("退出(X)");
exit.addActionListener(this);

menu1.add(newmake);
menu1.add(open);
menu1.add(save);
menu1.add(saveas);
menu1.addSeparator();
menu1.add(pageset);
menu1.add(print);
menu1.addSeparator();
menu1.add(exit);

che=new MenuItem("撤销(U)");
che.setShortcut(new MenuShortcut(KeyEvent.VK_Z));
cut=new MenuItem("剪切(T)");
cut.addActionListener(this);
cut.setShortcut(new MenuShortcut(KeyEvent.VK_X));
copy=new MenuItem("复制(C)");
copy.addActionListener(this);
copy.setShortcut(new MenuShortcut(KeyEvent.VK_C));
paste=new MenuItem("粘贴(P)");
paste.addActionListener(this);
paste.setShortcut(new MenuShortcut(KeyEvent.VK_V));
del=new MenuItem("删除(L)");
del.addActionListener(this);
del.setShortcut(new MenuShortcut(KeyEvent.VK_D));
search=new MenuItem("查找(F)...");
search.setShortcut(new MenuShortcut(KeyEvent.VK_F));
s_next=new MenuItem("查找下一个(N)");
s_next.setShortcut(new MenuShortcut(KeyEvent.VK_F3));
replace=new MenuItem("替换(R)...");
replace.setShortcut(new MenuShortcut(KeyEvent.VK_H));
trans=new MenuItem("转到(G)...");
trans.setShortcut(new MenuShortcut(KeyEvent.VK_G));
trans.addActionListener(this);
save_all=new MenuItem("全选(A)");
save_all.setShortcut(new MenuShortcut(KeyEvent.VK_A));
save_all.addActionListener(this);
data_time=new MenuItem("日期/时间(D)");
data_time.setShortcut(new MenuShortcut(KeyEvent.VK_F5));
data_time.addActionListener(this);

menu2.add(che);
menu2.addSeparator();
menu2.add(cut);
menu2.add(copy);
menu2.add(paste);
menu2.add(del);
menu2.addSeparator();
menu2.add(search);
menu2.add(s_next);
menu2.add(replace);
menu2.add(trans);
menu2.addSeparator();
menu2.add(save_all);
menu2.add(data_time);

auto_newline=new CheckboxMenuItem("自动换行(W)");//尚未实现
auto_newline.addActionListener(this);
letter=new MenuItem("字体(F)...");//尚未实现
menu3.add(auto_newline);
menu3.add(letter);

statusbar=new MenuItem("状态栏(S)");
statusbar.setEnabled(false);
menu4.add(statusbar);

help1=new MenuItem("帮助主题(H)");
help2=new MenuItem("关于记事本(A)");
menu5.add(help1);
menu5.add(help2);

bar.add(menu1);
bar.add(menu2);
bar.add(menu3);
bar.add(menu4);
bar.add(menu5);

setMenuBar(bar);

tex=new TextArea();

add(tex,BorderLayout.CENTER);

setBounds(300,50,600,600);
setVisible(true);
validate();
addWindowListener(new WindowAdapter()
{

public void windowClosing(WindowEvent e)
{

System.exit(0);
}

});

}

public void actionPerformed(ActionEvent e)
{

if(e.getSource()==open)
{
opener.setVisible(true);
tex.setText("你打开的文件为:"+opener.getFile()+"\n文件所在目录为:"+opener.getDirectory());

}
if(e.getSource()==save)
{
saver.setVisible(true);
tex.setText("你保存文件为:"+saver.getFile()+"\n文件所在目录为:"+saver.getDirectory());

}
if(e.getSource()==saveas)
{
save_as.setVisible(true);
tex.setText("你另存的文件为:"+save_as.getFile()+"\n文件所在目录为:"+save_as.getDirectory());

}
if(e.getSource()==exit)
{
System.exit(0);

}

if(e.getSource()==newmake)
{
//if(tex.getText()!=null)这里不可以判断内容的有无,只能通过内容的长度,来判断是否输入了内容
if(tex.getText().length()!=0)
{
int k=JOptionPane.showConfirmDialog(this,"文件的文字已经改变,想保存文件吗?","确认对话框",JOptionPane.YES_NO_OPTION);

if(k==JOptionPane.YES_OPTION)
{
saver.setVisible(true);
tex.setText(null);
}

if(k==JOptionPane.NO_OPTION)
{
tex.setText(null);
}
}
else
{

tex.setText("你已经新建一个文件");

}

}

if(e.getSource()==print)
{
p=getToolkit().getPrintJob(this,"ok",null);
g=p.getGraphics();
g.translate(120,200);
tex.printAll(g);
g.dispose();
p.end();

}
if(e.getSource()==trans)//未实现
{

dia1.setVisible(true);
//dia1.setCaretPosition();

}
if(e.getSource()==save_all)
{
tex.selectAll();//全选

}

if(e.getSource()==data_time)
{
Date d=new Date();
tex.append(d.toString());

}

if(e.getSource()==pageset)
{
p=getToolkit().getPrintJob(this,"ok",null);
g=p.getGraphics();
g.translate(120,200);
tex.printAll(g);
g.dispose();
p.end();

}

if(e.getSource()==copy)
{

String temp=tex.getSelectedText();
StringSelection text=new StringSelection(temp);
clipboard.setContents(text,null);

}

else if(e.getSource()==cut)
{

String temp=tex.getSelectedText();
StringSelection text=new StringSelection(temp);
clipboard.setContents(text,null);

int start=tex.getSelectionStart();
int end=tex.getSelectionEnd();
tex.replaceRange("",start,end);

}

else if(e.getSource()==paste)
{

Transferable contents=clipboard.getContents(this);
DataFlavor flavor=DataFlavor.stringFlavor;
if(contents.isDataFlavorSupported(flavor))
{

try{

String str=(String)contents.getTransferData(flavor);
tex.append(str);

}

catch(Exception ee){}

}

}

if(e.getSource()==del)
{
int start=tex.getSelectionStart();
int end=tex.getSelectionEnd();
tex.replaceRange("",start,end);

}

//if(e.getSource()==auto_newline)
//{

//System.out.println("自动换行");

//}

}

}

class MyDialog extends Dialog implements ActionListener
{

TextField t1;
Button but1,but2;
MyDialog(Frame f,String s,boolean b)
{
super(f,s,b);
t1=new TextField(10);
but1=new Button("确定");
but2=new Button("取消");
setLayout(new FlowLayout());
add(t1);
add(but1);
add(but2);
but1.addActionListener(this);
but2.addActionListener(this);
setBounds(320,150,200,100);
validate();

}

public void actionPerformed(ActionEvent e)
{
if(e.getSource()==but1||e.getSource()==but2)
{
setVisible(false);
}

}

}

如何用java一步步编出一个记事本程序
答:如何用java一步步编出一个记事本程序 我想开始做这个项目,但是不知道从哪里入手,请大家教一下我~但是不用提供那些长长的代码了,我有很多了,我要了解的是它的步骤,以及要具备那些基础等,请大家尽量帮一下我,这对我... 我想开始做这个项目,但是不知道从哪里入手,请大家教一下我~但是不用提供那些长长的代码...

求用java语言编写一个记事本程序、
答:super("记事本");//Container ct=getContentPane();//以下三句是设置编辑区域及滚动条 ta = new JTextArea();JScrollPane sp = new JScrollPane(ta);add(sp);JMenuBar mb = new JMenuBar();//设置文件菜单 JMenu mu1 = new JMenu("文件(F)",true);mu1.setMnemonic('F');//设置快捷键按...

求Java记事本源代码
答:setTitle("我的记事本");setSize(500, 600);setContentPane(createContentPane());//添加主面板 } /*创建主面板*/ private JPanel createContentPane() { JPanel pane = new JPanel(new BorderLayout());pane.add(BorderLayout.NORTH, createChocePane());//添加菜单栏 pane.add(createAreaPane...

java的一个简单记事本程序设计
答:意思即是:设计一个java程序,通过按钮“字体”、“颜色”设置,... java的字体Font类、GraphicsEnvironment类编程问题:利用Font类、画图环境类,把系统字体全部抽出来,包括颜色、字体。意思即是:设计一个java程序,通过按钮“字体”、“颜色”设置,可以把里面的文本格式改变,相当一个“记事本”吧!注意:不用功能太强大,...

用java编写记事本(输入,打开,保存功能就行)或者计算器(实现加减乘除就...
答:import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Calculator extends JFrame implements ActionListener { private JTextField text;StringBuffer sb1 = new StringBuffer(); //参数一 StringBuffer sb2 = new StringBuffer(); //参数二 private double b;private double...

怎么学习java中的一个框架?
答:8.Java日志框架 本套课程是针对有Java基础的小伙伴进行讲解,由浅入深详细讲解每个知识点以及编程思想,系统完整的帮助小伙伴建立完备的Java日志系统知识体系以及高性能的日志框架选型。Java日志框架教程,由浅入深全面精讲多种日志框架(log4j、slf4j、logback、jul、juc、springboot )9. 微服务框架-Spring...

求个用JAVA编写的记事本程序!先谢谢了!!
答:this.setTitle("记事本");Toolkit tool=this.getToolkit();//窗口图标!Image myimage=tool.getImage("戒指.jpg");this.setIconImage(myimage);setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ exit();} });menu...

java框架有哪些常用框架?
答:Spring Web MVC是一种基于Java的实现了Web MVC设计模式的请求驱动类型的轻量级Web框架,即使用了MVC架构模式的思想,将web层进行职责解耦,基于请求驱动指的就是使用请求-响应模型,框架的目的就是帮助我们简化开发,Spring Web MVC也是要简化我们日常Web开发的。 模型(Model )封装了应用程序的数据和一般他们会组成的POJO。

求一个用JAVA写的简单的记事本源代码程序
答:import java.awt.*;import java.awt.event.*;import java.io.*;import java.awt.datatransfer.*;class MyMenuBar extends MenuBar{ public MyMenuBar(Frame parent){ parent.setMenuBar(this);} public void addMenus(String [] menus){ for(int i=0;i<menus.length;i++)add(new Menu(menus[i...

谁能帮我写个Java的记事本程序
答:super("记事本");Toolkit tk=Toolkit.getDefaultToolkit();Image image=tk.getImage("jishiben.jpg"); //设置图表 this.setIconImage(image);container=getContentPane();container.setLayout(new BorderLayout());actionEventHandler actionHandler=new actionEventHandler();frame=new JFrame();wi...

IT评价网,数码产品家用电器电子设备等点评来自于网友使用感受交流,不对其内容作任何保证

联系反馈
Copyright© IT评价网