RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
java家谱图代码,如何编写家谱世系图

Java课程设计源代码 家族亲属关系查询系统

public class Beetle extends Insect {

网站设计制作过程拒绝使用模板建站;使用PHP+MYSQL原生开发可交付网站源代码;符合网站优化排名的后台管理系统;成都网站建设、做网站收费合理;免费进行网站备案等企业网站建设一条龙服务.我们是一家持续稳定运营了10余年的成都创新互联网站建设公司。

private int k = printInit("Beetle.k initialized");

public Beetle(){

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

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

}

private static int x2 = printInit("static Beetle.x2 initialized");

public static void main(String[] args){

System.out.println("Beetle constructor");

Beetle b = new Beetle();

}

}

利用java编写代码实现如下功能,需要全部代码

很简单的应用,为了节省字数,代码注释我就不加了

首先是显示层,LoinWindow:

import java.awt.FlowLayout;

import java.awt.GridBagConstraints;

import java.awt.GridBagLayout;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.FocusEvent;

import java.awt.event.FocusListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JTextField;

import javax.swing.border.EmptyBorder;

public class LoinWindow extends JFrame implements ActionListener, FocusListener {

private JPanel mainPanel, namePanel, btnPanel;

private JTextField tfName, tfPsd;

private JButton btnLogin, btnCancel;

private static final int WIDTH = 300;

private static final int HEIGHT = 200;

private LoginService service = new LoginService();

public LoinWindow() {

super("登录窗体");

}

public void launch() {

setSize(WIDTH, HEIGHT);

setVisible(true);

setDefaultCloseOperation(EXIT_ON_CLOSE);

GridLayout mainLayout = new GridLayout(2, 1);

mainLayout.setVgap(10);

mainPanel = new JPanel(mainLayout);

GridBagLayout nameLayout = new GridBagLayout();

namePanel = new JPanel(nameLayout);

namePanel.setBorder(new EmptyBorder(10, 10, 10, 10));

JLabel nameLabel = new JLabel("姓名:");

tfName = new JTextField();

JLabel psdLabel = new JLabel("密码:");

tfPsd = new JTextField();

JLabel blank = new JLabel(" ");

namePanel.add(nameLabel);

namePanel.add(tfName);

namePanel.add(blank);

namePanel.add(psdLabel);

namePanel.add(tfPsd);

GridBagConstraints s = new GridBagConstraints();

s.fill = GridBagConstraints.BOTH;

s.gridwidth = 1;

s.weightx = 0;

s.weighty = 0;

nameLayout.setConstraints(nameLabel, s);

s.gridwidth = 0;

s.weightx = 1;

s.weighty = 0;

nameLayout.setConstraints(tfName, s);

s.gridwidth = 0;

s.weightx = 4;

s.weighty = 0;

nameLayout.setConstraints(blank, s);

s.gridwidth = 1;

s.weightx = 0;

s.weighty = 0;

nameLayout.setConstraints(psdLabel, s);

s.gridwidth = 3;

s.weightx = 1;

s.weighty = 0;

nameLayout.setConstraints(tfPsd, s);

FlowLayout btnLayout = new FlowLayout();

btnLayout.setAlignment(FlowLayout.CENTER);

btnPanel = new JPanel(btnLayout);

btnLogin = new JButton("确定");

btnCancel = new JButton("取消");

btnPanel.add(btnLogin);

btnPanel.add(btnCancel);

btnCancel.addActionListener(this);

btnLogin.addActionListener(this);

mainPanel.add(namePanel);

mainPanel.add(btnPanel);

setContentPane(mainPanel);

tfName.addFocusListener(this);

tfPsd.addFocusListener(this);

pack();

setSize(WIDTH, HEIGHT);

setLocationRelativeTo(null);

}

@Override

public void actionPerformed(ActionEvent e) {

Object source = e.getSource();

if(source == btnCancel) {

System.exit(0);

} else if(source == btnLogin) {

String username = tfName.getText();

String password = tfPsd.getText();

boolean success = service.login(username, password);

if(success) {

warn("成功", "登录成功!");

} else {

warn("失败", "您输入的用户名或密码错误 !");

}

}

}

@Override

public void focusGained(FocusEvent arg0) {

}

@Override

public void focusLost(FocusEvent e) {

Object source = e.getSource();

if(source == tfName) {

String username = tfName.getText();

try {

service.matchUsername(username);

} catch (LoginException e1) {

warn("验证错误", e1.getMessage());

}

} else if(source == tfPsd) {

String password = tfPsd.getText();

try {

service.matchPassword(password);

} catch (LoginException e1) {

warn("验证错误", e1.getMessage());

}

}

}

private void warn(String title, String msg) {

JOptionPane.showMessageDialog(null, msg, title, JOptionPane.INFORMATION_MESSAGE);

}

public static void main(String[] args) {

new LoinWindow().launch();

}

}

然后是模型层:LoginDao

public class LoginDao {

public boolean login(String username, String password) {

if(username.equals("admin")  password.equals("12345")) {

return true;

}

return false;

}

}

LoginService

import java.util.regex.Pattern;

public class LoginService {

private static final Pattern LOGIN_PATTERN = Pattern.compile("[a-zA-Z]+");

private static final Pattern PASSWORD_PATTERN = Pattern.compile("[1-9]+");

private LoginDao dao = new LoginDao();

public boolean matchUsername(String username) throws LoginException {

if(null == username || username.isEmpty()) {

return false;

}

if(!LOGIN_PATTERN.matcher(username).matches()) {

throw new LoginException("您输入的用户名不合法,请输入英文!");

}

return true;

}

public boolean matchPassword(String password) throws LoginException {

if(null == password || password.isEmpty()) {

return false;

}

if(!PASSWORD_PATTERN.matcher(password).matches()) {

throw new LoginException("您输入的密码不合法,请输入数字!");

}

return true;

}

public boolean login(String username, String password) {

if(null == username || username.isEmpty()) {

return false;

}

if(null == password || password.isEmpty()) {

return false;

}

if(!dao.login(username, password)) {

return false;

}

return true;

}

}

LoginException

public class LoginException extends Exception {

public LoginException(String arg0) {

super(arg0);

}

}

不知道分层设计思想是不是我想的这样

哪位大侠可以帮我写一段java代码!是关于根据数据库里的数据来形成一个动态树形图

这是代码,你可以自己调试一下。

数据结构如下:

CREATE TABLE dtree (

id int,

pid int,

name varchar(200),

url varchar(200),

title varchar(200),

target varchar(200),

icon varchar(200),

iconopen varchar(200),

opened bit);

为了实现获取数据库变量功能,需要建立一个DTree类,并编译生成CLASS文件,放入\WEB-INF\classes文件夹下。

DTree类代码如下:

package work3;

public class DTree {

private int id;

private int pid;

private String name;

private String url;

private String title;

private String target;

private String icon;

private String iconOpen;

private int opened;

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public int getPid() {

return pid;

}

public void setPid(int pid) {

this.pid = pid;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getUrl() {

return url;

}

public void setUrl(String url) {

this.url = url;

}

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

public String getTarget() {

return target;

}

public void setTarget(String target) {

this.target = target;

}

public String getIcon() {

return icon;

}

public void setIcon(String icon) {

this.icon = icon;

}

public String getIconOpen() {

return iconOpen;

}

public void setIconOpen(String iconOpen) {

this.iconOpen = iconOpen;

}

public int getOpened() {

return opened;

}

public void setOpened(int opened) {

this.opened = opened;

}

}

work3.jsp代码如下:

%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%

%@ page import="java.sql.*"%

jsp:useBean id='settree' scope="application" class="work3.DTree" /

!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

""

html

head

meta http-equiv="Content-Type" content="text/html; charset=GB18030"

link rel="StyleSheet" href="dtree.css" type="text/css" /

script type="text/javascript" src="dtree.js"/script

titledTree in MySQL/title

/head

body

h2

Example

/h2

div class="dtree"

p

a href="javascript: d.openAll();"open all/a |

a href="javascript: d.closeAll();"close all/a

/p

script type="text/javascript"

!--

d = new dTree('d');

%

//驱动程序名

String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";

//数据库用户名

String userName = "sa";

//密码

String userPwd = "1";

//数据库名

String dbName = "master";

//表名

String tableName = "dtree";

//连接字符串

String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName="+dbName;

//加载驱动

Class.forName(driverName).newInstance();

//连接数据库

java.sql.Connection conn = DriverManager.getConnection(url,userName,userPwd);

//得到Statement实例

java.sql.Statement statement = conn.createStatement();

//查询数据

String sql = "select * from " + tableName;

//返回结果

java.sql.ResultSet rs = statement.executeQuery(sql);

//获取变量

while (rs.next()) {

settree.setId(rs.getInt(1));

settree.setPid(rs.getInt(2));

settree.setName(rs.getString(3));

settree.setUrl(rs.getString(4));

settree.setTitle(rs.getString(5));

settree.setTarget(rs.getString(6));

settree.setIcon(rs.getString(7));

settree.setIconOpen(rs.getString(8));

settree.setOpened(rs.getInt(9));

if(settree.getPid()==0)

settree.setOpened(1);

%

d.add(%=settree.getId()%,%=settree.getPid()%,'%=settree.getName()%','%=settree.getUrl()%','%=settree.getTitle()%','%=settree.getTarget()%','','',%=settree.getOpened()%);

%

}

%

document.write(d);

//--

/script

/div

/body

/html

求一个简单的java代码:(图形界面)

import java.awt.Color;

import java.awt.Dimension;

import java.awt.Toolkit;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JDialog;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class vv extends JDialog {

private static final long serialVersionUID = 1L;

private JLabel l_Id = new JLabel("登陆账户", JLabel.CENTER);

private JLabel l_pw = new JLabel("登陆密码", JLabel.CENTER);

private JTextField t_Id = new JTextField(10);

private JPasswordField t_pw = new JPasswordField(10);

private JButton btnLogin;

private JButton btnClose;

public vv() {

super();

setResizable(false);

getContentPane().setBackground(new Color(225, 225, 225));

getContentPane().setLayout(null);

initialize();

}

protected void initialize() {

setTitle("系统登录");

l_Id.setBounds(48, 43, 53, 25);

t_Id.setBounds(110, 43, 150, 25);

l_pw.setBounds(48, 93, 53, 25);

t_pw.setBounds(110, 93, 150, 25);

getContentPane().add(l_Id);

getContentPane().add(l_pw);

getContentPane().add(t_Id);

getContentPane().add(t_pw);

btnLogin = new JButton();

btnLogin.setText("登 录");

btnLogin.setBounds(70, 142, 85, 28);

btnLogin.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

addBtnLoginActionListener();

}

});

getContentPane().add(btnLogin);

btnClose = new JButton();

btnClose.setText("关 闭");

btnClose.setBounds(175, 142, 85, 28);

btnClose.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

dispose();

System.exit(-1);

}

});

getContentPane().add(btnClose);

}

private void addBtnLoginActionListener() {

String user = t_Id.getText();

String password = new String(t_pw.getPassword());

if (user.equals("")) {

JOptionPane.showMessageDialog(this, "帐号不可为空", "Caution",

JOptionPane.WARNING_MESSAGE);

return;

}

if (password.equals("")) {

JOptionPane.showMessageDialog(this, "密码不可为空", "Caution",

JOptionPane.WARNING_MESSAGE);

return;

}

String sql = "select * FROM login WHERE id = '" + user + "' and pw = '"

+ password + "'";

boolean success = false;

// TODO:数据校验 success = executeQuery(sql);

if (success) {

// TODO: 如果数据校验成功 显示主界面 并关闭登录界面

JOptionPane.showMessageDialog(this, "成功登录", "提示",

JOptionPane.INFORMATION_MESSAGE);

this.dispose();

} else {

JOptionPane.showMessageDialog(this, "帐号或密码错误!", "警告",

JOptionPane.WARNING_MESSAGE);

t_pw.requestFocus(); // 密码框选中

}

}

public Dimension getPreferredSize() {

return new Dimension(320, 170);

}

public void show() {

Toolkit tk = Toolkit.getDefaultToolkit();

Dimension screen = tk.getScreenSize();

Dimension d = getSize();

this.setLocation((screen.width - d.width) / 2,

(screen.height - d.height) / 2);

// 输入密码后回车相当于点击了登录按钮

getRootPane().setDefaultButton(btnLogin);

t_pw.requestFocus();

setDefaultCloseOperation(DISPOSE_ON_CLOSE);

setSize(300, 220);

super.show();

}

public static void main(String[] args) {

vv loginFrame = new vv();

loginFrame.setVisible(true);

}

}

希望对你有帮助

用JAVA帮我画个简单的拓扑图,要用java实现,麻烦写出代码,图是有向带权的,一共六个节点(0-5)

用JAVA帮我画个简单的拓扑图,要用java实现,麻烦写出代码,图是有向带权的,一共六个节点(0-5),节点到节点的关系如下 0 1 5(表示节点0到节点1的距离为5)

0 5 10

1 4 3

2 0 2

2 1 28

2 3 12

3 1 6

4 3 1

4 5 1

JAVA编译简易画图板代码

import java.applet.*;

import java.awt.*;

import java.awt.event.*;

import java.util.*;

import javax.swing.*;

import java.awt.geom.*;

import java.io.*;

class Point implements Serializable

{

int x,y;

Color col;

int tool;

int boarder;

Point(int x, int y, Color col, int tool, int boarder)

{

this.x = x;

this.y = y;

this.col = col;

this.tool = tool;

this.boarder = boarder;

}

}

class paintboard extends Frame implements ActionListener,MouseMotionListener,MouseListener,ItemListener

{

int x = -1, y = -1;

int con = 1;//画笔大小

int Econ = 5;//橡皮大小

int toolFlag = 0;//toolFlag:工具标记

//toolFlag工具对应表:

//(0--画笔);(1--橡皮);(2--清除);

//(3--直线);(4--圆);(5--矩形);

Color c = new Color(0,0,0); //画笔颜色

BasicStroke size = new BasicStroke(con,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);//画笔粗细

Point cutflag = new Point(-1, -1, c, 6, con);//截断标志

Vector paintInfo = null;//点信息向量组

int n = 1;

FileInputStream picIn = null;

FileOutputStream picOut = null;

ObjectInputStream VIn = null;

ObjectOutputStream VOut = null;

// *工具面板--画笔,直线,圆,矩形,多边形,橡皮,清除*/

Panel toolPanel;

Button eraser, drLine,drCircle,drRect;

Button clear ,pen;

Choice ColChoice,SizeChoice,EraserChoice;

Button colchooser;

Label 颜色,大小B,大小E;

//保存功能

Button openPic,savePic;

FileDialog openPicture,savePicture;

paintboard(String s)

{

super(s);

addMouseMotionListener(this);

addMouseListener(this);

paintInfo = new Vector();

/*各工具按钮及选择项*/

//颜色选择

ColChoice = new Choice();

ColChoice.add("black");

ColChoice.add("red");

ColChoice.add("blue");

ColChoice.add("green");

ColChoice.addItemListener(this);

//画笔大小选择

SizeChoice = new Choice();

SizeChoice.add("1");

SizeChoice.add("3");

SizeChoice.add("5");

SizeChoice.add("7");

SizeChoice.add("9");

SizeChoice.addItemListener(this);

//橡皮大小选择

EraserChoice = new Choice();

EraserChoice.add("5");

EraserChoice.add("9");

EraserChoice.add("13");

EraserChoice.add("17");

EraserChoice.addItemListener(this);

////////////////////////////////////////////////////

toolPanel = new Panel();

clear = new Button("清除");

eraser = new Button("橡皮");

pen = new Button("画笔");

drLine = new Button("画直线");

drCircle = new Button("画圆形");

drRect = new Button("画矩形");

openPic = new Button("打开图画");

savePic = new Button("保存图画");

colchooser = new Button("显示调色板");

//各组件事件监听

clear.addActionListener(this);

eraser.addActionListener(this);

pen.addActionListener(this);

drLine.addActionListener(this);

drCircle.addActionListener(this);

drRect.addActionListener(this);

openPic.addActionListener(this);

savePic.addActionListener(this);

colchooser.addActionListener(this);

颜色 = new Label("画笔颜色",Label.CENTER);

大小B = new Label("画笔大小",Label.CENTER);

大小E = new Label("橡皮大小",Label.CENTER);

//面板添加组件

toolPanel.add(openPic);

toolPanel.add(savePic);

toolPanel.add(pen);

toolPanel.add(drLine);

toolPanel.add(drCircle);

toolPanel.add(drRect);

toolPanel.add(颜色); toolPanel.add(ColChoice);

toolPanel.add(大小B); toolPanel.add(SizeChoice);

toolPanel.add(colchooser);

toolPanel.add(eraser);

toolPanel.add(大小E); toolPanel.add(EraserChoice);

toolPanel.add(clear);

//工具面板到APPLET面板

add(toolPanel,BorderLayout.NORTH);

setBounds(60,60,900,600); setVisible(true);

validate();

//dialog for save and load

openPicture = new FileDialog(this,"打开图画",FileDialog.LOAD);

openPicture.setVisible(false);

savePicture = new FileDialog(this,"保存图画",FileDialog.SAVE);

savePicture.setVisible(false);

openPicture.addWindowListener(new WindowAdapter()

{

public void windowClosing(WindowEvent e)

{ openPicture.setVisible(false); }

});

savePicture.addWindowListener(new WindowAdapter()

{

public void windowClosing(WindowEvent e)

{ savePicture.setVisible(false); }

});

addWindowListener(new WindowAdapter()

{

public void windowClosing(WindowEvent e)

{ System.exit(0);}

});

}

public void paint(Graphics g)

{

Graphics2D g2d = (Graphics2D)g;

Point p1,p2;

n = paintInfo.size();

if(toolFlag==2)

g.clearRect(0,0,getSize().width,getSize().height);//清除

for(int i=0; in ;i++){

p1 = (Point)paintInfo.elementAt(i);

p2 = (Point)paintInfo.elementAt(i+1);

size = new BasicStroke(p1.boarder,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);

g2d.setColor(p1.col);

g2d.setStroke(size);

if(p1.tool==p2.tool)

{

switch(p1.tool)

{

case 0://画笔

Line2D line1 = new Line2D.Double(p1.x, p1.y, p2.x, p2.y);

g2d.draw(line1);

break;

case 1://橡皮

g.clearRect(p1.x, p1.y, p1.boarder, p1.boarder);

break;

case 3://画直线

Line2D line2 = new Line2D.Double(p1.x, p1.y, p2.x, p2.y);

g2d.draw(line2);

break;

case 4://画圆

Ellipse2D ellipse = new Ellipse2D.Double(p1.x, p1.y, Math.abs(p2.x-p1.x) , Math.abs(p2.y-p1.y));

g2d.draw(ellipse);

break;

case 5://画矩形

Rectangle2D rect = new Rectangle2D.Double(p1.x, p1.y, Math.abs(p2.x-p1.x) , Math.abs(p2.y-p1.y));

g2d.draw(rect);

break;

case 6://截断,跳过

i=i+1;

break;

default :

}//end switch

}//end if

}//end for

}

public void itemStateChanged(ItemEvent e)

{

if(e.getSource()==ColChoice)//预选颜色

{

String name = ColChoice.getSelectedItem();

if(name=="black")

{c = new Color(0,0,0); }

else if(name=="red")

{c = new Color(255,0,0);}

else if(name=="green")

{c = new Color(0,255,0);}

else if(name=="blue")

{c = new Color(0,0,255);}

}

else if(e.getSource()==SizeChoice)//画笔大小

{

String selected = SizeChoice.getSelectedItem();

if(selected=="1")

{

con = 1;

size = new BasicStroke(con,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);

}

else if(selected=="3")

{

con = 3;

size = new BasicStroke(con,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);

}

else if(selected=="5")

{con = 5;

size = new BasicStroke(con,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);

}

else if(selected=="7")

{con = 7;

size = new BasicStroke(con,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);

}

else if(selected=="9")

{con = 9;

size = new BasicStroke(con,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);

}

}

else if(e.getSource()==EraserChoice)//橡皮大小

{

String Esize = EraserChoice.getSelectedItem();

if(Esize=="5")

{ Econ = 5*2; }

else if(Esize=="9")

{ Econ = 9*2; }

else if(Esize=="13")

{ Econ = 13*2; }

else if(Esize=="17")

{ Econ = 17*3; }

}

}

public void mouseDragged(MouseEvent e)

{

Point p1 ;

switch(toolFlag){

case 0://画笔

x = (int)e.getX();

y = (int)e.getY();

p1 = new Point(x, y, c, toolFlag, con);

paintInfo.addElement(p1);

repaint();

break;

case 1://橡皮

x = (int)e.getX();

y = (int)e.getY();

p1 = new Point(x, y, null, toolFlag, Econ);

paintInfo.addElement(p1);

repaint();

break;

default :

}

}

public void mouseMoved(MouseEvent e) {}

public void update(Graphics g)

{

paint(g);

}

public void mousePressed(MouseEvent e)

{

Point p2;

switch(toolFlag){

case 3://直线

x = (int)e.getX();

y = (int)e.getY();

p2 = new Point(x, y, c, toolFlag, con);

paintInfo.addElement(p2);

break;

case 4: //圆

x = (int)e.getX();

y = (int)e.getY();

p2 = new Point(x, y, c, toolFlag, con);

paintInfo.addElement(p2);

break;

case 5: //矩形

x = (int)e.getX();

y = (int)e.getY();

p2 = new Point(x, y, c, toolFlag, con);

paintInfo.addElement(p2);

break;

default :

}

}

public void mouseReleased(MouseEvent e)

{

Point p3;

switch(toolFlag){

case 0://画笔

paintInfo.addElement(cutflag);

break;

case 1: //eraser

paintInfo.addElement(cutflag);

break;

case 3://直线

x = (int)e.getX();

y = (int)e.getY();

p3 = new Point(x, y, c, toolFlag, con);

paintInfo.addElement(p3);

paintInfo.addElement(cutflag);

repaint();

break;

case 4: //圆

x = (int)e.getX();

y = (int)e.getY();

p3 = new Point(x, y, c, toolFlag, con);

paintInfo.addElement(p3);

paintInfo.addElement(cutflag);

repaint();

break;

case 5: //矩形

x = (int)e.getX();

y = (int)e.getY();

p3 = new Point(x, y, c, toolFlag, con);

paintInfo.addElement(p3);

paintInfo.addElement(cutflag);

repaint();

break;

default:

}

}

public void mouseEntered(MouseEvent e){}

public void mouseExited(MouseEvent e){}

public void mouseClicked(MouseEvent e){}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==pen)//画笔

{toolFlag = 0;}

if(e.getSource()==eraser)//橡皮

{toolFlag = 1;}

if(e.getSource()==clear)//清除

{

toolFlag = 2;

paintInfo.removeAllElements();

repaint();

}

if(e.getSource()==drLine)//画线

{toolFlag = 3;}

if(e.getSource()==drCircle)//画圆

{toolFlag = 4;}

if(e.getSource()==drRect)//画矩形

{toolFlag = 5;}

if(e.getSource()==colchooser)//调色板

{

Color newColor = JColorChooser.showDialog(this,"调色板",c);

c = newColor;

}

if(e.getSource()==openPic)//打开图画

{

openPicture.setVisible(true);

if(openPicture.getFile()!=null)

{

int tempflag;

tempflag = toolFlag;

toolFlag = 2 ;

repaint();

try{

paintInfo.removeAllElements();

File filein = new File(openPicture.getDirectory(),openPicture.getFile());

picIn = new FileInputStream(filein);

VIn = new ObjectInputStream(picIn);

paintInfo = (Vector)VIn.readObject();

VIn.close();

repaint();

toolFlag = tempflag;

}

catch(ClassNotFoundException IOe2)

{

repaint();

toolFlag = tempflag;

System.out.println("can not read object");

}

catch(IOException IOe)

{

repaint();

toolFlag = tempflag;

System.out.println("can not read file");

}

}

}

if(e.getSource()==savePic)//保存图画

{

savePicture.setVisible(true);

try{

File fileout = new File(savePicture.getDirectory(),savePicture.getFile());

picOut = new FileOutputStream(fileout);

VOut = new ObjectOutputStream(picOut);

VOut.writeObject(paintInfo);

VOut.close();

}

catch(IOException IOe)

{

System.out.println("can not write object");

}

}

}

}//end paintboard

public class pb

{

public static void main(String args[])

{ new paintboard("画图程序"); }

}


分享题目:java家谱图代码,如何编写家谱世系图
当前链接:http://lswzjz.com/article/hcoigi.html