简单Java课程设计 截图+代码

合集下载

Java编程实现屏幕截图(截屏)代码总结(转载)

Java编程实现屏幕截图(截屏)代码总结(转载)

Java编程实现屏幕截图(截屏)代码总结(转载)转载⾃:⽅法⼀:import java.awt.Desktop;import java.awt.Dimension;import java.awt.Rectangle;import java.awt.Robot;import java.awt.Toolkit;import java.awt.image.BufferedImage;import java.io.File;import javax.imageio.ImageIO;public class CaptureScreen {public static void captureScreen(String fileName, String folder) throws Exception {Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();Rectangle screenRectangle = new Rectangle(screenSize);Robot robot = new Robot();BufferedImage image = robot.createScreenCapture(screenRectangle);//保存路径File screenFile = new File(fileName);if (!screenFile.exists()) {screenFile.mkdir();}File f = new File(screenFile, folder);ImageIO.write(image, "png", f);//⾃动打开if (Desktop.isDesktopSupported()&& Desktop.getDesktop().isSupported(Desktop.Action.OPEN))Desktop.getDesktop().open(f);}public static void main(String[] args) {try {captureScreen("e:\\你好","11.png");} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}}⽅法⼆:package com.qiu.util;import java.io.*;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.awt.image.*;import javax.imageio.*;/*** ⼀个简单的屏幕抓图***/public class ScreenCapture {// test mainpublic static void main(String[] args) throws Exception {String userdir = System.getProperty("user.dir");File tempFile = new File("d:", "temp.png");ScreenCapture capture = ScreenCapture.getInstance();capture.captureImage();JFrame frame = new JFrame();JPanel panel = new JPanel();panel.setLayout(new BorderLayout());JLabel imagebox = new JLabel();panel.add(BorderLayout.CENTER, imagebox);imagebox.setIcon(capture.getPickedIcon());capture.saveToFile(tempFile);capture.captureImage();imagebox.setIcon(capture.getPickedIcon());frame.setContentPane(panel);frame.setSize(400, 300);frame.show();System.out.println("Over");}private ScreenCapture() {try {robot = new Robot();} catch (AWTException e) {System.err.println("Internal Error: " + e);e.printStackTrace();}JPanel cp = (JPanel) dialog.getContentPane();cp.setLayout(new BorderLayout());labFullScreenImage.addMouseListener(new MouseAdapter() {public void mouseReleased(MouseEvent evn) {isFirstPoint = true;pickedImage = fullScreenImage.getSubimage(recX, recY, recW,recH);dialog.setVisible(false);}});labFullScreenImage.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent evn) {if (isFirstPoint) {x1 = evn.getX();y1 = evn.getY();isFirstPoint = false;} else {x2 = evn.getX();y2 = evn.getY();int maxX = Math.max(x1, x2);int maxY = Math.max(y1, y2);int minX = Math.min(x1, x2);int minY = Math.min(y1, y2);recX = minX;recY = minY;recW = maxX - minX;recH = maxY - minY;labFullScreenImage.drawRectangle(recX, recY, recW, recH);}}public void mouseMoved(MouseEvent e) {labFullScreenImage.drawCross(e.getX(), e.getY());}});cp.add(BorderLayout.CENTER, labFullScreenImage);dialog.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); dialog.setAlwaysOnTop(true);dialog.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize());dialog.setUndecorated(true);dialog.setSize(dialog.getMaximumSize());dialog.setModal(true);}// Singleton Patternpublic static ScreenCapture getInstance() {return defaultCapturer;}/** 捕捉全屏慕 */public Icon captureFullScreen() {fullScreenImage = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));ImageIcon icon = new ImageIcon(fullScreenImage);return icon;}/** 捕捉屏幕的⼀个矫形区域 */public void captureImage() {fullScreenImage = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));ImageIcon icon = new ImageIcon(fullScreenImage);labFullScreenImage.setIcon(icon);dialog.setVisible(true);}/** 得到捕捉后的BufferedImage */public BufferedImage getPickedImage() {return pickedImage;}/** 得到捕捉后的Icon */public ImageIcon getPickedIcon() {return new ImageIcon(getPickedImage());}/*** 储存为⼀个⽂件,为PNG格式** @deprecated replaced by saveAsPNG(File file)**/@Deprecatedpublic void saveToFile(File file) throws IOException {ImageIO.write(getPickedImage(), defaultImageFormater, file);}/** 储存为⼀个⽂件,为PNG格式 */public void saveAsPNG(File file) throws IOException {ImageIO.write(getPickedImage(), "png", file);}/** 储存为⼀个JPEG格式图像⽂件 */public void saveAsJPEG(File file) throws IOException {ImageIO.write(getPickedImage(), "JPEG", file);}/** 写⼊⼀个OutputStream */public void write(OutputStream out) throws IOException {ImageIO.write(getPickedImage(), defaultImageFormater, out);}// singleton design patternprivate static ScreenCapture defaultCapturer = new ScreenCapture();private int x1, y1, x2, y2;private int recX, recY, recH, recW; // 截取的图像private boolean isFirstPoint = true;private BackgroundImage labFullScreenImage = new BackgroundImage();private Robot robot;private BufferedImage fullScreenImage;private BufferedImage pickedImage;private String defaultImageFormater = "png";private JDialog dialog = new JDialog();}/** 显⽰图⽚的Label */class BackgroundImage extends JLabel {public void paintComponent(Graphics g) {super.paintComponent(g);g.drawRect(x, y, w, h);String area = Integer.toString(w) + " * " + Integer.toString(h);g.drawString(area, x + (int) w / 2 - 15, y + (int) h / 2);g.drawLine(lineX, 0, lineX, getHeight());g.drawLine(0, lineY, getWidth(), lineY);}public void drawRectangle(int x, int y, int width, int height) {this.x = x;this.y = y;h = height;w = width;repaint();}public void drawCross(int x, int y) {lineX = x;lineY = y;repaint();}int lineX, lineY;int x, y, h, w;⽅法三:因为有最⼩化到系统托盘,还是需要⼀张名为bg.gif作为托盘图标,图⽚应放在同级⽬录下,否则会空指针异常。

java编写截图工具

java编写截图工具
this.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
this.setVisible(true);
this.repaint();
}
public static void main(String[] args) {
new AWTpicture();
}
public void paint(
}
// 缓存图片
public void update(Graphics g) {
if (bis == null) {
bis = this.createImage(frameWidth, frameHeight);
button2.setBackground(Color.darkGray);
button2.addActionListener(new MyTakePicture(this));
button2.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
button.addActionListener(this);
panel = new Panel();
button = new Button("退出");
button.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
button.setBackground(Color.green);
button2 = new Button("截取");
try {
robot = new Robot();
} catch (AWTException e) {

java大作业附运行截图及代码

java大作业附运行截图及代码

《Java程序设计》上机报告学院通信工程学院专业通信工程学生姓名梁芷馨学生学号150****0045第一次上机报告必做题题目1:课本P53 12;题目1的运行结果截图:题目1的源程序:package ch1;public class Car {public static void main(String args[]){Carinf obj1=new Carinf("本田","黑色",1500,5);System.out.println(obj1.show());}}class Carinf{String name;String color;double weight;int passenger;Carinf(String s,String b,double d,int i) { name=s;color=b;weight=d;passenger=i;}String show(){return"品牌: "+name+" 颜色: "+color+" 自重:"+weight+"公斤搭载的人数: "+passenger;}}题目2:课本P53 15;题目2的运行结果截图:题目2的源程序:package ch1;public class Reverse {public static void main(String args[]){System.out.println("逆序输出");for(int i=args[0].length()-1;i>=0;i--){System.out.println(args[0].charAt(i));}}}选作题题目3:参考下列要求,修改Snowman.java:(1)在图片的右上角添加文本;(2)给雪人增加更多的装饰;(3)给画面添加更多内容,比如云朵,圣诞树,房屋等。

java万年历设计源码(附截图)..

java万年历设计源码(附截图)..

import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.table.DefaultTableModel;import java.io.*;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;import java.util.GregorianCalendar;import java.util.Locale;import java.util.TimeZone;public class h_main1 extends JFrame implements ActionListener, MouseListener {private Calendar cld = Calendar.getInstance();//获取一个Calendar类的实例对象private String[] astr = { "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" };private DefaultTableModel dtm = new DefaultTableModel(null, astr); private JTable table = new JTable(dtm);private JScrollPane sp = new JScrollPane(table);private JButton bLastYear = new JButton("上一年");private JButton bNextYear = new JButton("下一年");private JButton bLastMonth = new JButton("上月");private JButton bNextMonth = new JButton("下月");private JButton bAddClock = new JButton("确定");private JPanel p1 = new JPanel(); // 装入控制日期的按钮模块private JPanel p2 = new JPanel(new GridLayout(3,2));private JPanel p3 = new JPanel(new BorderLayout());private JPanel p4 = new JPanel(new GridLayout(2,1));private JPanel p5 = new JPanel(new BorderLayout());private JPanel p6 = new JPanel(new GridLayout(2,2));private JPanel p7 = new JPanel(new GridLayout(2,1));private JPanel p8 = new JPanel(new BorderLayout());private JComboBox timeBox = newJComboBox(TimeZone.getAvailableIDs());//对所有支持时区进行迭代,获取所有的id;private JTextField jtfYear = new JTextField(5);// jtfYeaar年份显示输入框private JTextField jtfMonth = new JTextField(2);// jtfMouth月份显示输入框private JTextField timeField=new JTextField();private JTextField h1=new JTextField(5);private JTextField m1=new JTextField(5);private static JTextArea jta = new JTextArea(10,5);private JScrollPane jsp = new JScrollPane(jta);private JTextArea jta1 = new JTextArea(5,4);private JScrollPane jsp1 = new JScrollPane(jta1);private JLabel l = new JLabel("你可以向年份输入框中输入年份,提高查询效率");private JLabel lt = new JLabel();private JLabel ld = new JLabel();private JLabel ts=new JLabel("请在右边下拉菜单选择你要选择的城市");private JLabel clock= new JLabel("闹钟");private JLabel notice= new JLabel("备忘录");private JLabel hour = new JLabel("小时");private JLabel minute= new JLabel("分钟");private JLabel lu = new JLabel("农历和节气");private JLabel null1=new JLabel();private int lastTime;private String localTime = null;private String s = null;private SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy 年MM月dd日hh时mm分ss秒");public h_main1() {super("My Calender");// 框架命名this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 窗口关闭函数this.getContentPane().setLayout(new BorderLayout(5, 5));jta.setLineWrap(true);// 长度大于分配长度时候则换行table.setGridColor(Color.GRAY);// 星期之间的网格线是灰色的table.setColumnSelectionAllowed(true);// 将table中的列设置为可选择的table.setSelectionBackground(Color.GRAY);// 当选定某一天时背景颜色为黑色table.setSelectionForeground(Color.GREEN);table.setBackground(new Color(184,207, 229));// 日期显示表格为浅蓝色table.setFont(new Font("黑体", Font.BOLD, 24));// 日期数字字体格式table.setRowHeight(30);// 表格的高度table.addMouseListener(this); // 鼠标监听器jtfYear.addActionListener(this);// 可输入年份的文本框// 为各个按钮添加监听函数bLastYear.addActionListener(this);bNextYear.addActionListener(this);bLastMonth.addActionListener(this);bNextMonth.addActionListener(this);bAddClock.addActionListener(this);timeBox.addItemListener(new TimeSelectedChangedListener());// 将按钮添加到Jpane上p1.add(bLastYear);p1.add(jtfYear);// 年份输入文本框p1.add(bNextYear);p1.add(bLastMonth);p1.add(jtfMonth);p1.add(bNextMonth);p2.add(clock);p2.add(bAddClock);p2.add(hour);p2.add(h1);p2.add(minute);p2.add(m1);p3.add(jsp, BorderLayout.SOUTH);p3.add(lu,BorderLayout.CENTER);p3.add(ld, BorderLayout.NORTH);p4.add(l);p4.add(lt);p5.add(p4, BorderLayout.SOUTH);p5.add(sp, BorderLayout.CENTER);p5.add(p1, BorderLayout.NORTH);p6.add(ts);p6.add(timeBox);p6.add(null1);p6.add(timeField);p7.add(notice);p7.add(jsp1);p8.add(p2,BorderLayout.CENTER);p8.add(p7,BorderLayout.SOUTH);this.getContentPane().add(p3, BorderLayout.EAST);this.getContentPane().add(p5, BorderLayout.CENTER);this.getContentPane().add(p6,BorderLayout.SOUTH);this.getContentPane().add(p8,BorderLayout.WEST);String[] strDate = DateFormat.getDateInstance().format(new Date()) .split("-");// 获取日期cld.set(Integer.parseInt(strDate[0]), Integer.parseInt(strDate[1]) - 1,0);showCalendar(Integer.parseInt(strDate[0]),Integer.parseInt(strDate[1]), cld);jtfMonth.setEditable(false);// 设置月份文本框为不可编辑jtfYear.setText(strDate[0]);jtfMonth.setText(strDate[1]);this.showTextArea(strDate[2]);ld.setFont(new Font("新宋体", Font.BOLD, 24));new Timer(lt).start();new TimeThread().start();this.setBounds(200, 200, 700, 350);this.setResizable(false);this.setVisible(true);}public void showCalendar(int localYear, int localMonth, Calendar cld) {int Days = getDaysOfMonth(localYear, localMonth) +cld.get(Calendar.DAY_OF_WEEK) -2;Object [] ai = new Object[7];lastTime = 0;for (int i = cld.get(Calendar.DAY_OF_WEEK)-1; i <= Days; i++){ai[i%7] =String.valueOf(i-(cld.get(Calendar.DAY_OF_WEEK)-2));if (i%7 == 6){dtm.addRow(ai);ai = new Object[7];lastTime++;}}dtm.addRow(ai);}public int getDaysOfMonth(int Year, int Month) {if(Month==1||Month==3||Month==5||Month==7||Month==8||Month==10 ||Month==12){return 31;}if(Month==4||Month==6||Month==9||Month==11){return 30;}if(Year%4==0&&Year%100!=0||Year%400==0)//闰年{return 29;}else {return 28;}}public void actionPerformed(ActionEvent e){if(e.getSource() == jtfYear || e.getSource() == bLastYear || e.getSource() == bNextYear ||e.getSource() == bLastMonth || e.getSource() == bNextMonth||e.getSource()==bAddClock){int m, y;try//控制输入的年份正确,异常控制{if (jtfYear.getText().length() != 4){throw new NumberFormatException();}y = Integer.parseInt(jtfYear.getText());m = Integer.parseInt(jtfMonth.getText());}catch (NumberFormatException ex){JOptionPane.showMessageDialog(this, "请输入4位0-9的数字!", "年份有误", JOptionPane.ERROR_MESSAGE);return;}ld.setText("没有选择日期");for (int i = 0; i < lastTime+1; i++){ dtm.removeRow(0);}if(e.getSource() ==bLastYear){ jtfYear.setText(String.valueOf(--y)); }if(e.getSource() ==bNextYear){jtfYear.setText(String.valueOf(++y)); }if(e.getSource() == bLastMonth){if(m == 1){jtfYear.setText(String.valueOf(--y));m = 12;jtfMonth.setText(String.valueOf(m));}else{jtfMonth.setText(String.valueOf(--m));}}if(e.getSource() == bNextMonth){if(m == 12){jtfYear.setText(String.valueOf(++y));m = 1;jtfMonth.setText(String.valueOf(m));}else{jtfMonth.setText(String.valueOf(++m));}}cld.set(y, m-1, 0);showCalendar(y, m, cld);}if(e.getSource()==bAddClock){try{Clock clock=new Clock();clock.start();if(Integer.parseInt(h1.getText())<0||Integer.parseInt(h1.getText())>23|| Integer.parseInt(m1.getText())<0||Integer.parseInt(m1.getText())>59) {throw(new Exception());}}catch(Exception ex){JOptionPane.showMessageDialog(this, "时数应该为0——23,分钟数应该为0——59", "时间有误",JOptionPane.ERROR_MESSAGE);}}}public void mouseClicked(MouseEvent e){jta.setText(null);int r = table.getSelectedRow();int c = table.getSelectedColumn();if (table.getValueAt(r,c) == null){ld.setText("没有选择日期");}else{this.showTextArea(table.getValueAt(r,c));}}private void showTextArea(Object selected){ //在这里将公历化为农历ld.setText(jtfYear.getText()+"年"+jtfMonth.getText()+"月"+selected+"日");}public static void main(String[] args){JFrame.setDefaultLookAndFeelDecorated(true);JDialog.setDefaultLookAndFeelDecorated(true);new h_main1();jta.setText(today());}private void updateTimeText(String timeZoneId) {if(timeZoneId != null){TimeZone timeZone = TimeZone.getTimeZone(timeZoneId);dateFormat.setTimeZone(timeZone);Calendar calendar = Calendar.getInstance();calendar.setTimeZone(timeZone);timeField.setText(dateFormat.format(calendar.getTime()));}else{timeField.setText(null);}}private class TimeSelectedChangedListener implements ItemListener {public void itemStateChanged(ItemEvent e) {if (e.getStateChange()==ItemEvent.SELECTED) {if (e.getItem() instanceof String) {s = e.getItem().toString();}}}}private class TimeThread extends Thread{public void run(){while(true){updateTimeText(s);try{Thread.sleep(100);}catch(InterruptedException e){e.printStackTrace();}}}}class Clock extends Thread //闹钟线程{public void run(){while(true){Calendar now=Calendar.getInstance();int h=now.get(Calendar.HOUR_OF_DAY);//获取小时int mi=now.get(Calendar.MINUTE);//获取分钟int s=now.get(Calendar.SECOND);//获取秒钟int ss=h*3600+mi*60+s;if(ss>(Integer.parseInt(h1.getText())*3600+Integer.parseInt(m1.getText() )*60+0)&&ss<Integer.parseInt(h1.getText())*3600+(Integer.parseInt(m1.getText ()+5)*60+0)){jta1.setText("闹钟启动");}else{jta1.setText("没有正在提示的闹钟");}}}}class Timer extends Thread //显示系统时间{private JLabel lt;private SimpleDateFormat fy = newSimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z");private boolean b=true;public Timer(JLabel lt){this.lt=lt;}public void run(){while(true){try{lt.setText(fy.format(new Date()));this.sleep(1000);}catch(InterruptedException ex){ex.printStackTrace();}}}}final private static long[] lunarInfo = new long[] { 0x04bd8,0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554,0x056a0, 0x09ad0, 0x055d2, 0x04ae0, 0x0a5b6, 0x0a4d0,0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0,0x14977, 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40,0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, 0x06566,0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3,0x092e0, 0x1c8d7, 0x0c950, 0x0d4a0, 0x1d8a6, 0x0b550,0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950,0x0b557, 0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0,0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0, 0x0aea6,0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263,0x0d950, 0x05b57, 0x056a0, 0x096d0, 0x04dd5, 0x04ad0,0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0,0x195a6, 0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a,0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, 0x04af5,0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0,0x0ab60, 0x096d5, 0x092e0, 0x0c960, 0x0d954, 0x0d4a0,0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0,0x0cab5, 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9,0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, 0x07954,0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0,0x0d260, 0x0ea65, 0x0d530, 0x05aa0, 0x076a3, 0x096d0,0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520,0x0dd45, 0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577,0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0 };final private static int[] year20 = new int[] { 1, 4, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };final private static int[] year19 = new int[] { 0, 3, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 };final private static int[] year2000 = new int[] { 0, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };public final static String[] nStr1 = new String[] { "", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一","十二" };private final static String[] Gan = new String[] { "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" };private final static String[] Zhi = new String[] { "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥" };private final static String[] Animals = new String[] { "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪" };private final static String[] solarTerm = new String[] { "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏","小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至" };private final static String[] sFtv = new String[] { "0101*元旦", "0214 情人节", "0308 妇女节", "0312 植树节", "0315 消费者权益日","0401 愚人节", "0501 劳动节", "0504 青年节", "0512 护士节", "0601 儿童节", "0701 建党节", "0801 建军节", "0808 父亲节", "0909 毛泽东逝世纪念", "0910 教师节", "0928 孔子诞辰", "1001*国庆节", "1006 老人节", "1024 联合国日", "1112 孙中山诞辰", "1220 澳门回归","1225 圣诞节", "1226 毛泽东诞辰" };private final static String[] lFtv = new String[] { "0101*农历春节", "0115 元宵节", "0505 端午节", "0707 七夕情人节", "0815 中秋节", "0909 重阳节", "1208 腊八节", "1224 小年", "0100*除夕" };/*** 传回农历y年的总天数** @param y* @return*/final private static int lYearDays(int y) {int i, sum = 348;for (i = 0x8000; i > 0x8; i >>= 1) {if ((lunarInfo[y - 1900] & i) != 0)sum += 1;}return (sum + leapDays(y));}/*** 传回农历y年闰月的天数** @param y* @return*/final private static int leapDays(int y) {if (leapMonth(y) != 0) {if ((lunarInfo[y - 1900] & 0x10000) != 0)return 30;elsereturn 29;} elsereturn 0;}/*** 传回农历y年闰哪个月1-12 , 没闰传回0 ** @param y* @return*/final private static int leapMonth(int y) {return (int) (lunarInfo[y - 1900] & 0xf);}/*** 传回农历y年m月的总天数** @param y* @param m* @return*/final private static int monthDays(int y, int m) {if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0) return 29;elsereturn 30;}/*** 传回农历y年的生肖** @param y* @return*/final public static String AnimalsYear(int y) {return Animals[(y - 4) % 12];}/*** 传入月日的offset 传回干支,0=甲子** @param num* @return*/final private static String cyclicalm(int num) {return (Gan[num % 10] + Zhi[num % 12]);}/*** 传入offset 传回干支, 0=甲子** @param y* @return*/final public static String cyclical(int y) {int num = y - 1900 + 36;return (cyclicalm(num));}/*** 传出农历.year0 .month1 .day2 .yearCyl3 .monCyl4 .dayCyl5 .isLeap6 ** @param y* @param m* @return*/final private long[] Lunar(int y, int m) {long[] nongDate = new long[7];int i = 0, temp = 0, leap = 0;Date baseDate = new GregorianCalendar(1900 + 1900, 1,31).getTime();Date objDate = new GregorianCalendar(y + 1900, m, 1).getTime();long offset = (objDate.getTime() - baseDate.getTime()) / 86400000L;if (y < 2000)offset += year19[m - 1];if (y > 2000)offset += year20[m - 1];if (y == 2000)offset += year2000[m - 1];nongDate[5] = offset + 40;nongDate[4] = 14;for (i = 1900; i < 2050 && offset > 0; i++) {temp = lYearDays(i);offset -= temp;nongDate[4] += 12;}if (offset < 0) {offset += temp;i--;nongDate[4] -= 12;}nongDate[0] = i;nongDate[3] = i - 1864;leap = leapMonth(i); // 闰哪个月nongDate[6] = 0;for (i = 1; i < 13 && offset > 0; i++) {// 闰月if (leap > 0 && i == (leap + 1) && nongDate[6] == 0) {--i;nongDate[6] = 1;temp = leapDays((int) nongDate[0]);} else {temp = monthDays((int) nongDate[0], i);}// 解除闰月if (nongDate[6] == 1 && i == (leap + 1))nongDate[6] = 0;offset -= temp;if (nongDate[6] == 0)nongDate[4]++;}if (offset == 0 && leap > 0 && i == leap + 1) {if (nongDate[6] == 1) {nongDate[6] = 0;} else {nongDate[6] = 1;--i;--nongDate[4];}}if (offset < 0) {offset += temp;--i;--nongDate[4];}nongDate[1] = i;nongDate[2] = offset + 1;return nongDate;}/*** 传出y年m月d日对应的农历.year0 .month1 .day2 .yearCyl3 .monCyl4 .dayCyl5 .isLeap6 ** @param y* @param m* @param d* @return*/final public static long[] calElement(int y, int m, int d) {long[] nongDate = new long[7];int i = 0, temp = 0, leap = 0;Date baseDate = new GregorianCalendar(0 + 1900, 0, 31).getTime();Date objDate = new GregorianCalendar(y, m - 1, d).getTime();long offset = (objDate.getTime() - baseDate.getTime()) / 86400000L;nongDate[5] = offset + 40;nongDate[4] = 14;for (i = 1900; i < 2050 && offset > 0; i++) {temp = lYearDays(i);offset -= temp;nongDate[4] += 12;}if (offset < 0) {offset += temp;i--;nongDate[4] -= 12;}nongDate[0] = i;nongDate[3] = i - 1864;leap = leapMonth(i); // 闰哪个月nongDate[6] = 0;for (i = 1; i < 13 && offset > 0; i++) {// 闰月if (leap > 0 && i == (leap + 1) && nongDate[6] == 0) { --i;nongDate[6] = 1;temp = leapDays((int) nongDate[0]);} else {temp = monthDays((int) nongDate[0], i);}// 解除闰月if (nongDate[6] == 1 && i == (leap + 1))nongDate[6] = 0;offset -= temp;if (nongDate[6] == 0)nongDate[4]++;}if (offset == 0 && leap > 0 && i == leap + 1) {if (nongDate[6] == 1) {nongDate[6] = 0;} else {nongDate[6] = 1;--i;--nongDate[4];}}if (offset < 0) {offset += temp;--i;--nongDate[4];}nongDate[1] = i;nongDate[2] = offset + 1;return nongDate;}public final static String getChinaDate(int day) { String a = "";if (day == 10)return "初十";if (day == 20)return "二十";if (day == 30)return "三十";int two = (int) ((day) / 10);if (two == 0)a = "初";if (two == 1)a = "十";if (two == 2)a = "廿";if (two == 3)a = "三";int one = (int) (day % 10);switch (one) {case 1:a += "一";break;case 2:a += "二";break;case 3:a += "三";break;case 4:a += "四";break;case 5:a += "五";break;case 6:a += "六";break;case 7:a += "七";break;case 8:a += "八";break;case 9:a += "九";break;}return a;}public static String today() {Calendar today =Calendar.getInstance(Locale.SIMPLIFIED_CHINESE);int year = today.get(Calendar.YEAR);int month = today.get(Calendar.MONTH) + 1;int date = today.get(Calendar.DATE);long[] l = calElement(year, month, date);StringBuffer sToday = new StringBuffer();try {sToday.append(sdf.format(today.getTime()));sToday.append(" 农历");sToday.append(cyclical(year));sToday.append('(');sToday.append(AnimalsYear(year));sToday.append(")年");sToday.append(nStr1[(int) l[1]]);sToday.append("月");sToday.append(getChinaDate((int) (l[2])));return sToday.toString();} finally {sToday = null;}}private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy年M月d日EEEEE");/*** 农历日历工具使用演示** @param args*/public void mouseEntered(MouseEvent e) { }public void mouseExited(MouseEvent e) { }public void mousePressed(MouseEvent e) { }public void mouseReleased(MouseEvent e) { }}。

JAVA编程任务四的设计形考源代码截图

JAVA编程任务四的设计形考源代码截图

JAVA编程任务四的设计形考源代码截图一、前言本文档主要是对JAVA编程任务四的设计形考源代码截图进行详细解析,以便让读者更好地理解代码的实现过程和功能。

在本文档中,我们将对代码截图中的关键部分进行解读,并给出相应的注释。

二、代码截图解析以下是JAVA编程任务四的设计形考源代码截图:public class Main {public static void main(String[] args) {// 创建一个ArrayList来存储学生信息ArrayList<Student> students = new ArrayList<>();// 创建三个学生对象并添加到ArrayList中Student student1 = new Student("张三", 20, "计算机科学与技术");Student student2 = new Student("李四", 21, "软件工程");Student student3 = new Student("王五", 22, "网络工程");students.add(student1);students.add(student2);students.add(student3);// 输出所有学生信息for (Student student : students) {System.out.println("姓名:" + student.getName() + ", 年龄:" + student.getAge() + ", 专业:" + student.getMajor());}}}class Student {private String name;private int age;private String major;// 构造函数public Student(String name, int age, String major) { = name;this.age = age;this.major = major;}// 获取学生姓名public String getName() {return name;}// 设置学生姓名public void setName(String name) { = name;}// 获取学生年龄public int getAge() {return age;}// 设置学生年龄public void setAge(int age) {this.age = age;}// 获取学生专业public String getMajor() {return major;}// 设置学生专业public void setMajor(String major) { this.major = major;}}1. 主函数main主函数`main`是程序的入口,负责创建一个`ArrayList`来存储学生信息,并创建三个学生对象添加到`ArrayList`中。

java根据坐标截取图片实例代码

java根据坐标截取图片实例代码

java根据坐标截取图⽚实例代码java 根据坐标截取图⽚实例代码:代码中有不是注释,很好看懂!package com.json.test;import java.awt.Rectangle;import java.awt.image.BufferedImage;import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.util.Iterator;import javax.imageio.ImageIO;import javax.imageio.ImageReadParam;import javax.imageio.ImageReader;import javax.imageio.stream.ImageInputStream;public class OperateImage {// ===源图⽚路径名称如:c:\1.jpgprivate String srcpath ;// ===剪切图⽚存放路径名称.如:c:\2.jpgprivate String subpath ;// ===剪切点x坐标private int x ;private int y ;// ===剪切点宽度private int width ;private int height ;public OperateImage() {}public OperateImage( int x, int y, int width, int height) {this .x = x ;this .y = y ;this .width = width ;this .height = height ;}/*** 对图⽚裁剪,并把裁剪完蛋新图⽚保存。

*/public void cut()throws IOException {FileInputStream is = null ;ImageInputStream iis = null ;try {// 读取图⽚⽂件is =new FileInputStream(srcpath);/** 返回包含所有当前已注册 ImageReader 的 Iterator,这些 ImageReader* 声称能够解码指定格式。

java截图课程设计

java截图课程设计

java截图课程设计一、教学目标本课程旨在通过Java编程语言实现截图功能,让学生掌握Java编程的基本语法、面向对象编程思想,以及图形用户界面(GUI)的设计和开发。

具体目标如下:1.知识目标:–掌握Java基本语法和数据结构;–理解面向对象编程的基本概念,如类、对象、封装、继承和多态;–学习Java GUI编程,了解Swing和JavaFX框架;–了解操作系统中截图的基本原理。

2.技能目标:–能够运用Java语言编写简单的程序;–能够使用Java面向对象编程方法解决实际问题;–能够设计和开发图形用户界面,实现截图功能;–能够调试和优化程序,提高代码质量。

3.情感态度价值观目标:–培养学生对编程的兴趣和热情,提高学生解决问题的能力;–培养学生团队合作精神,提高沟通与协作能力;–培养学生勇于探索、不断创新的精神,提高自主学习能力。

二、教学内容本课程的教学内容主要包括以下几个部分:1.Java基本语法和数据结构:字符串、数组、列表、集合、映射、基本数据类型、控制结构、循环、函数等;2.面向对象编程:类、对象、封装、继承、多态、抽象类、接口等;3.Java GUI编程:Swing和JavaFX框架,组件、容器、布局管理器、事件处理等;4.截图功能实现:屏幕分辨率、图像处理、文件存储等;5.编程实践:编写一个简单的截图工具,进行功能测试和优化。

三、教学方法为了提高教学效果,本课程将采用以下教学方法:1.讲授法:讲解Java基本语法、面向对象编程思想和GUI编程基础;2.案例分析法:分析实际截图工具的代码,引导学生掌握编程技巧;3.实验法:让学生动手编写代码,实现截图功能,培养实际操作能力;4.讨论法:分组讨论编程问题,培养学生团队合作和沟通能力。

四、教学资源为了支持本课程的教学,我们将准备以下教学资源:1.教材:《Java编程思想》、《Java GUI编程实战》;2.参考书:《Java核心技术》、《Swing编程指南》;3.多媒体资料:教学PPT、视频教程、在线编程练习平台;4.实验设备:计算机、网络环境、编程软件(如Eclipse、IntelliJIDEA)。

java代码实现截图功能(屏幕截图)

java代码实现截图功能(屏幕截图)

java代码实现截图功能(屏幕截图)复制代码代码如下:import java.awt.Dimension;import java.awt.Rectangle;import java.awt.Robot;import java.awt.Toolkit;import java.awt.image.BufferedImage;import java.io.File;import javax.imageio.ImageIO;/******************************************************************** 该JavaBean可以直接在其他Java应⽤程序中调⽤,实现屏幕的"拍照"* This JavaBean is used to snapshot the GUI in a* Java application! You can embeded* it in to your java application source code, and us* it to snapshot the right GUI of the application* @see javax.ImageIO* @author liluqun* @version 1.0*****************************************************/public class Test{private String fileName; //⽂件的前缀private String defaultName = "GuiCamera";static int serialNum=0;private String imageFormat; //图像⽂件的格式private String defaultImageFormat="png";Dimension d = Toolkit.getDefaultToolkit().getScreenSize();/***************************************************************** 默认的⽂件前缀为GuiCamera,⽂件格式为PNG格式* The default construct will use the default* Image file surname "GuiCamera",* and default image format "png"****************************************************************/public Test() {fileName = defaultName;imageFormat=defaultImageFormat;}/***************************************************************** @param s the surname of the snapshot file* @param format the format of the image file,* it can be "jpg" or "png"* 本构造⽀持JPG和PNG⽂件的存储****************************************************************/public Test(String s,String format) {fileName = s;imageFormat=format;}/***************************************************************** 对屏幕进⾏拍照* snapShot the Gui once****************************************************************/public void snapShot() {try {//拷贝屏幕到⼀个BufferedImage对象screenshotBufferedImage screenshot = (new Robot()).createScreenCapture(new Rectangle(0, 0, (int) d.getWidth(), (int) d.getHeight()));serialNum++;//根据⽂件前缀变量和⽂件格式变量,⾃动⽣成⽂件名String name=fileName+String.valueOf(serialNum)+"."+imageFormat; File f = new File(name);System.out.print("Save File "+name);//将screenshot对象写⼊图像⽂件ImageIO.write(screenshot, imageFormat, f);System.out.print("..Finished!\n");}catch (Exception ex) {System.out.println(ex);}}public static void main(String[] args){Test cam= new Test("d:\\Hello", "png");//cam.snapShot();}}。

实现屏幕截图的小程序 java课程设计

实现屏幕截图的小程序 java课程设计

实现安全工作方针与目标的措施经济与管理学院信息管理与信息系统专业《java实验周》报告(2015/2016学年第一学期)学生姓名:学生班级:学生学号:指导教师:2015年12月25日实现屏幕截图的小程序一、实验题目实现屏幕截图的小程序二、实验要求编程一个应用小程序,能够具有屏幕截图的功能,截图的具体实现有:(1)显示出工作区域,即能够截屏的面积;(2)鼠标可以随意滑动进行截图;(3)将所截取的图片保存在想要保存的位置;(4)程序结束后可以退出整个应用。

三、程序流程图3.1 业务流程图四、技术原理程序的主类是cutScreen,继承自无边框的框架JWindow;cutScreen()是一个定义屏幕尺寸的构造方法;使用方法mousePressed(MouseEvent e)来监听当前鼠标点击的动作;用方法mouseReleased(MouseEvent e)监听鼠标松开时,显示操作窗口;方法mouseDragged(MouseEvent e)监听拖动鼠标;paint(Graphics g)画出指定的工作区域;saveImage()保存图像。

工具栏ToolsWindow类,继承自有边框的框架JFrame;方法init()用来设置布局方式为BorderLayout;run()捕捉屏幕截图。

五、附实验代码import java.awt.*;import java.awt.event.*;import java.awt.image.BufferedImage;import java.awt.image.RescaleOp;import java.io.File;import java.io.IOException;import java.text.SimpleDateFormat;import java.util.Date;import javax.imageio.ImageIO;import javax.swing.*;import javax.swing.filechooser.FileNameExtensionFilter;import javax.swing.filechooser.FileSystemView;//Jwindow 是一个无边框的框架public class cutScreen extends JWindow {//beginX 开始的横坐标; beginY开始的纵坐标p rivate int beginX, beginY, endX, endY;p rivate BufferedImage image = null;p rivate BufferedImage tempImage = null;p rivate BufferedImage saveImage = null;p rivate ToolsWindow tools = null;//构造方法p ublic cutScreen() throws AWTException, IOException {// 获取屏幕尺寸宽和高int width = Toolkit.getDefaultToolkit().getScreenSize().width;int height = Toolkit.getDefaultToolkit().getScreenSize().height;// 设置窗口大小//(0, 0, width, height)第一个0代表横坐标,第二个代表纵坐标this.setBounds(0, 0, width, height);// 截取屏幕Robot robot = new Robot();//参数Rectangle是代表工作区域image = robot.createScreenCapture(new Rectangle(0, 0, width, height));ImageIO.write(image, "jpg", new File("d:/1"));// 本窗口添加监听(适配器)this.addMouseListener(new MouseAdapter() {@Override//当前鼠标点击动作public void mousePressed(MouseEvent e) {beginX = e.getX();beginY = e.getY();if (tools != null) {tools.setVisible(false);}}@Overridepublic void mouseReleased(MouseEvent e) {// 鼠标松开时,显示操作窗口if (tools == null) {tools = new ToolsWindow(cutScreen.this, e.getX(), e.getY());} else {tools.setLocation(e.getX(), e.getY());}tools.setVisible(true);// 将此窗口置于前端,并可以将其设为焦点 Windowtools.toFront();}});// 监听拖动鼠标this.addMouseMotionListener(new MouseMotionAdapter() {@Overridepublic void mouseDragged(MouseEvent e) {// 鼠标拖动时,记录坐标并重绘窗口endX = e.getX();endY = e.getY();// 临时图像,用于缓冲屏幕区域放置屏幕闪烁Image tempImage2 = createImage(cutScreen.this.getWidth(),cutScreen.this.getHeight());Graphics g = tempImage2.getGraphics();g.drawImage(tempImage, 0, 0, null);int x = Math.min(beginX, endX);int y = Math.min(beginY, endY);int width2 = Math.abs(endX - beginX) + 1;int height2 = Math.abs(endY - beginY) + 1;g.drawRect(x - 1, y - 1, width2 + 1, height2 + 1);// 生成子区域流图片saveImage = image.getSubimage(x, y, width2, height2);//画出图片g.drawImage(saveImage, x, y, null);//绘制当前指定的区域的图片cutScreen.this.getGraphics().drawImage(tempImage2, 0, 0,cutScreen.this);}});}// @Override//画出指定的工作区域p ublic void paint(Graphics g) {//进行逐像素重缩放RescaleOp ro = new RescaleOp(0.8f, 0, null);tempImage = ro.filter(image, null);g.drawImage(tempImage, 0, 0, this);}// 保存图像到文件p ublic void saveImage() throws IOException {JFileChooser jfc = new JFileChooser();jfc.setDialogTitle("保存");// 文件过滤器,用户过滤可选择文件FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG", "jpg");jfc.setFileFilter(filter);// 初始化一个默认文件(此文件会生成到桌面上)// 生成时间SimpleDateFormat sdf = new SimpleDateFormat("yyyymmddHHmmss");String fileName = sdf.format(new Date());File filePath = FileSystemView.getFileSystemView().getHomeDirectory();File defaultFile = new File(filePath + File.separator + fileName + ".jpg");jfc.setSelectedFile(defaultFile);int flag = jfc.showSaveDialog(this);if (flag == JFileChooser.APPROVE_OPTION) {File file = jfc.getSelectedFile();String path = file.getPath();//System.out.println(path);// 检查文件后缀,放置用户忘记输入后缀或者输入不正确的后缀if (!(path.endsWith(".jpg") || path.endsWith(".JPG"))) {path += ".jpg";}// 写入文件ImageIO.write(saveImage, "jpg", new File(path));System.exit(0);}}/** 操作窗口*///ToolsWindow 内部类c lass ToolsWindow extends JFrame {private cutScreen parent;//构造函数(cutScreen,int x, int y)x代表鼠标释放位置的横坐标,public ToolsWindow(cutScreen parent, int x, int y) {this.parent = parent;this.init();this.setLocation(x, y);//让窗口里面的组建确定为最佳大小this.pack();this.setVisible(true);}private void init() {//设置布局方式为BorderLayoutthis.setLayout(new BorderLayout());//工具栏JToolBar toolBar = new JToolBar();// 保存按钮JButton saveButton = new JButton("保存");//匿名内部类添加监听saveButton.addActionListener(new ActionListener() { @Overridepublic void actionPerformed(ActionEvent e) {try {parent.saveImage();} catch (IOException e1) {e1.printStackTrace();}}});toolBar.add(saveButton);// 关闭按钮JButton closeButton = new JButton("关闭");closeButton.addActionListener(new ActionListener() { @Overridepublic void actionPerformed(ActionEvent e) {System.exit(0);}});toolBar.add(closeButton);this.add(toolBar, BorderLayout.CENTER);}}p ublic static void main(String[] args) {EventQueue.invokeLater(new Runnable() {@Overridepublic void run() {try {cutScreen cutScreen = new cutScreen();cutScreen.setVisible(true);} catch (Exception e) {e.printStackTrace();}}});}}六、实验结果图6.1 截图图6.2 保存七、个人总结一周的课程设计结束了,刚开始对所要设计的课题完全没有头绪,通过网上查找一些相关资料和同学的帮助,成功设计出能够实现屏幕截图的java程序。

JAVA编程语言设计形考四任务源代码截图

JAVA编程语言设计形考四任务源代码截图

JAVA编程语言设计形考四任务源代码截图任务一:编写一个简单的Java程序public class HelloWorld {public static void main(String[] args) {System.out.println("Hello, World!");}}任务二:实现一个求解阶乘的Java方法public class Factorial {public static int calculateFactorial(int num) {if (num == 0 || num == 1) {return 1;} else {return num * calculateFactorial(num - 1);}}}任务三:编写一个Java类,实现一个简单的计算器public class Calculator {public static int add(int num1, int num2) {return num1 + num2;}public static int subtract(int num1, int num2) {return num1 - num2;}public static int multiply(int num1, int num2) {return num1 * num2;}public static int divide(int num1, int num2) {if (num2 == 0) {throw new IllegalArgumentException("Cannot divide by zero!"); }return num1 / num2;}}任务四:实现一个简单的Java图书管理系统import java.util.ArrayList;import java.util.List;public class BookManagementSystem {private List<Book> books;public BookManagementSystem() {this.books = new ArrayList<>();}public void addBook(Book book) {books.add(book);}public void removeBook(Book book) {books.remove(book);}public List<Book> searchBooks(String keyword) { List<Book> searchResults = new ArrayList<>();for (Book book : books) {if (book.getTitle().contains(keyword) ||book.getAuthor().contains(keyword)) {searchResults.add(book);}}return searchResults;}}public class Book {private String title;private String author;public Book(String title, String author) {this.title = title;this.author = author;}public String getTitle() {return title;}public String getAuthor() {return author;}}以上是JAVA编程语言设计形考四任务的源代码截图。

JAVA设计形考任务四的程序语言源代码截图

JAVA设计形考任务四的程序语言源代码截图

JAVA设计形考任务四的程序语言源代码
截图
以下是任务四的程序语言源代码截图:
// 导入所需的包
import java.util.Scanner;
public class Task4 {
public static void main(String[] args) {
// 创建一个Scanner对象
Scanner scanner = new Scanner(System.in);
// 提示用户输入一个整数
System.out.print("请输入一个整数:");
int num = scanner.nextInt();
// 判断输入的整数是否为偶数
if (num % 2 == 0) {
System.out.println(num + "是偶数。

");
} else {
System.out.println(num + "是奇数。

");
}
// 关闭Scanner对象
scanner.close();
}
}
以上是一个简单的JAVA程序,功能是判断用户输入的整数是奇数还是偶数。

程序首先创建了一个Scanner对象,用于接收用户的输入。

然后,程序提示用户输入一个整数,并将用户输入的整数存储在变量`num`中。

接下来,程序通过判断`num`是否能被2整除来判断其是否为偶数。

最后,程序根据判断结果输出相应的提示信息。

最后,程序关闭了Scanner对象。

请注意,以上代码仅为示例,可能需要根据具体的需求进行修改。

Java实验八-Applet类及应用源码及截图

Java实验八-Applet类及应用源码及截图

//实验八第一题源程序import java.applet.Applet;import java.awt.*;public class CC extends Applet{private int init = 0;private int start = 0;private int destroy = 0;private int paint = 0;public void init(){init++;}public void start(){start++;}public void destroy(){destroy++;}public void paint(Graphics g){paint++;int x0=20,y0=150;g.drawLine(x0,y0,x0+200,y0);g.drawLine(x0,y0,x0,50);g.drawString("init()",40,165);g.drawString("start()",90,165);g.drawString("destroy()",130,165);g.drawString("paint()",190,165);g.setColor(Color.red);g.fillRect(25,150-init,40,init);g.setColor(Color.blue);g.fillRect(75,150-start,40,start);g.setColor(Color.yellow);g.fillRect(125,150-destroy,40,destroy);g.setColor(Color.green);g.fillRect(175,150-paint,40,paint);}}//第一题html文件<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE> Te8_1 </TITLE><META NAME="Generator" CONTENT="EditPlus"><META NAME="Author" CONTENT=""><META NAME="Keywords" CONTENT=""><META NAME="Description" CONTENT=""></HEAD><BODY><APPLET CODE="Te8_1" WIDTH="300" HEIGHT="300"></APPLET></BODY></HTML>//第二题源程序import java.applet.Applet;import java.applet.*;import java.awt.*;public class Te8_2 extends Applet{String str;int x,y,h,r,g,b;Font fnt;Color Col;public void init(){str=getParameter("string");h=Integer.parseInt(getParameter("size"));x=Integer.parseInt(getParameter("x1"));y=Integer.parseInt(getParameter("y1"));fnt=new Font("楷体_gb2312",Font.BOLD,h);r=Integer.parseInt(getParameter("r"));g=Integer.parseInt(getParameter("g"));b=Integer.parseInt(getParameter("b"));Col=new Color(r,g,b);}public void paint(Graphics g){g.setColor(Col);g.setFont(fnt);g.drawString(str,x,y);}}//第二题html文件<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Te8_2</TITLE><META NAME="Generator" CONTENT="EditPlus"><META NAME="Author" CONTENT=""><META NAME="Keywords" CONTENT=""><META NAME="Description" CONTENT=""></HEAD><BODY><APPLET code="Te8_2" width=300 height=200><PARAM name=string value="nihao"><PARAM name=r value="0"><PARAM name=g value="0"><PARAM name=b value="255"><PARAM name=size value="30"><PARAM name=x1 value="100"><PARAM name=y1 value="100"></APPLET></BODY></HTML>//第三题源程序import java.applet.Applet;import java.awt.*;public class Te8_3 extends Applet{public void paint(Graphics g){int w=15,h=15;int x0 =10, y0=20;g.setColor(Color.blue);g.fillRect(0, 0,1000,1000);//用指定宽度和高度画实心矩形g.setColor(Color.pink);g.fillRect(x0+50, y0+50, 150, 100);for(int i=0;i<30;i=i+2){g.setColor(Color.red);g.fillOval(x0+50+i*3,y0+50,w,h);try{Thread.sleep(500);}catch (InterruptedException e){}g.setColor(Color.pink);g.drawOval(x0+50+i*3,y0+50,w,h);g.fillOval(x0+50+i*3,y0+50,w,h);}for(int i=30;i>1;i=i-2){g.setColor(Color.red);g.fillOval(x0+50+i*3,y0+50,w,h);try{Thread.sleep(500);}catch (InterruptedException e){}g.setColor(Color.pink);g.drawOval(x0+50+i*3,y0+50,w,h);g.fillOval(x0+50+i*3,y0+50,w,h);}repaint();}}//第三题html文件<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE> Te8_3 </TITLE><META NAME="Generator" CONTENT="EditPlus"><META NAME="Author" CONTENT=""><META NAME="Keywords" CONTENT=""><META NAME="Description" CONTENT=""></HEAD><BODY><APPLET CODE="Te8_3" WIDTH="300" HEIGHT="300"></APPLET></BODY></HTML>//第四题源程序import java.applet.Applet;import java.awt.*;public class Te8_4 extends Applet{Image[] Im;int totalno=5;int currentno=0;public void init(){Im=new Image[totalno];for(int i=0;i<totalno;i++)Im[i]=getImage(getDocumentBase(),"z00"+(i+1)+".jpg");}public void paint(Graphics g){g.drawImage(Im[currentno],20,20,250,250,this);currentno=++currentno%totalno;try{Thread.sleep(800);}catch (InterruptedException e){}repaint();}}//第四题html文件<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE> Te8_4 </TITLE><META NAME="Generator" CONTENT="EditPlus"><META NAME="Author" CONTENT=""><META NAME="Keywords" CONTENT=""><META NAME="Description" CONTENT=""></HEAD><BODY><APPLET CODE="Te8_4" WIDTH="300" HEIGHT="300"></APPLET></BODY></HTML>。

JAVA 截图代码

JAVA 截图代码

package img;import java.awt.image.BufferedImage;import java.io.File;import java.io.FileNotFoundException;import java.io.IOException;import javax.imageio.ImageIO;public class ImgSub{public static void main(String[] args){String input = "D:\\1.jpg";String output = "D:\\2.jpg";BufferedImage img = readBufferedImage(input); //读取源图int startX = 0,startY = 0; //截图的起点int subWidth = img.getWidth()-100,subHeight = img.getHeight()-100 ; //截图后的大小BufferedImage outImg = new BufferedImage(subWidth,subHeight,BufferedImage.TYPE_INT_RGB);subImage(img, outImg, startX, startY, subWidth, subHeight);writeImg(output, outImg); //写出截好的图片}public static void subImage(BufferedImage src,BufferedImage dest,int startX,int startY,int subWidth,int subHeight){int i=0,j=0;try{for(i=0;i< subWidth;i++) //循环行y坐标{for (j = 0; j < subHeight; j++) //循环列x坐标dest.setRGB(i, j,src.getRGB(i+startX, j+startY)); //此处加上偏移量使截图刚好合适}} catch (RuntimeException e){System.out.println("i="+i+" j="+j);e.printStackTrace();}}public static BufferedImage readBufferedImage(String path){File file = new File(path);try{BufferedImage img = ImageIO.read(file);return img ;} catch (IOException e){e.printStackTrace();}return null ;}public static boolean writeImg(String outPath,BufferedImage img) {File file = new File(outPath);try{if(file.exists())file.delete();ImageIO.write(img, "jpg", file);return true ;} catch (FileNotFoundException e){e.printStackTrace();} catch (IOException e){e.printStackTrace();}return false ;};}。

java实现屏幕截图功能毕业设计与实现

java实现屏幕截图功能毕业设计与实现

java实现屏幕截图功能摘要捕捉图像方式灵活,主要可以捕捉整个屏幕、活动窗口、选定区域、固定区域、选定控件、选定菜单等,图像输出方式多样,主要包括文件、剪贴板、画图。

软件具有捕捉光标、设置捕捉前延时、显示屏幕放大镜、自定义捕捉热键、图像文件自动按时间或模板命名。

捕捉到的图像能够以保存图像文件、复制到剪贴板、等多种方式输出。

图像文件自动命名功能,能够对捕捉到的图片进行自动命名保存,可以设置根据时间或文件名模板自动保存。

捕捉图像预览功能,在捕捉完成后,显示预览窗口。

图像保存目录及格式设置功能,可以为捕捉的图像规定默认保存位置及图像格式,图像格式包括BMP、GIF、JPG、PNG、TIF等。

捕捉层叠菜单功能,在选定菜单捕捉时可以设置是否捕捉层叠(级联)菜单。

可以截取多个图片,分多层界面显示已截图片。

关键词:截图;保存;复制到剪切板Java implementation screenshot functionAbstractCapture the image flexibly, and the main can capture the whole screen, the active window, the selected region, fixed area, the selected control, select menu, image output way diverse, mainly including documents, clipboard, drawing.Software is to capture the cursor, set the delay before capture, display screen magnifier, custom capture hotkey, automatic image file on time or template name.Capture the image to save the image file, copied to the clipboard, a variety of ways, such as the output. Image file named function automatically, to be able to capture the image automatically named save, can be set according to time or template automatically saved in the file name.Capture the image preview function, after completion of the capture, display the preview window.Image save directory and format setting function, can be preserved to capture images of the provisions of the default location and image format, image format, including BMP, GIF, JPG, PNG, TIF, etc.When capture to capture the cascading menu function, the selected menu you can set whether to capture the cascading menu (cascade).Can capture multiple images, multi-layer interface has sectional image display.Key words:capture; Save; Copied to the clipboard目录摘要 (i)Abstract (ii)目录 (1)1 绪论 (1)1.1 选题背景 (1)1.2 课题研究内容 (1)2 开发平台及技术 (3)2.1 Eclipse (3)2.2 Java (3)2.2.1 历史起源 (4)2.2.2 基本组成 (4)2.2.3 主要特性 (4)2.2.4 基本术语 (5)3 可行性分析及开发环境的选择 (7)3.1 可行性分析 (7)3.1.1 技术可行性分析 (7)3.1.2 经济可行性分析 (7)3.1.3 法律可行性分析 (7)3.1.4 开发人员与进程可行性分析 (7)3.1.5 结论意见 (8)3.2 运行环境的选择 (8)3.3 开发工具的选择 (8)4 系统需求分析 (9)4.1 性能需求 (9)4.2 E-R图设计 (9)5 系统设计 (10)5.1 本系统的设计目标 (10)5.2 系统功能整体设计 (10)6 系统设计实现 (11)6.1 系统主界面实现 (11)6.2 系统截图实现 (12)6.2.1 图片的保存路径 (20)6.2.2 图片的保存格式 (22)7 系统测试与性能分析 (25)7.1 软件测试 (25)7.1.1 软件测试概述 (25)7.1.2 系统整体测试步骤 (25)7.2 截图软件系统测试 (26)7.2.1 保存选项测试 (26)7.2.2 复制到粘贴板选项测试 (26)7.3 测试结果评价 (26)总结 (27)参考文献 (28)致谢 (29)外文引用 (30)中文翻译 (37)1 绪论截图是由电脑截取的显示在屏幕或其他显示设备上的可视图像。

JAVA语言设计形考第四项任务源代码截图

JAVA语言设计形考第四项任务源代码截图

JAVA语言设计形考第四项任务源代码截

任务要求
编写一个Java程序,在控制台上打印出一个星形图案,要求如下:
1. 用户输入一个正整数n,表示星形的层数;
2. 程序根据用户输入的n,打印出相应层数的星形图案;
3. 星形图案的每一层由星号(*)和空格组成,星号表示填充的部分,空格表示空缺的部分;
4. 每一层的星号数量为奇数,中间一层为n个星号,其他层的星号数量递减,每层比上一层少2个;
5. 星形图案中心对齐。

源代码截图
![源代码截图](source_code.png)
代码说明
1. 程序首先获取用户输入的正整数n,并进行合法性判断;
2. 然后使用两层循环来打印星形图案,外层循环控制行数,内层循环控制每行的打印内容;
3. 内层循环根据当前行数和总层数n来确定每行的星号数量和空格数量;
4. 最后,通过控制台打印出星形图案。

示例输出
用户输入:5
*
***
**
******
**
用户输入:3
*
***
**
用户输入:7
*
***
**
******
**
******
**
以上是根据用户输入的不同层数所得到的星形图案。

注意事项
1. 用户输入的层数应为正整数,否则程序会提示错误并要求重新输入;
2. 如果用户输入的层数过大,星形图案可能无法在控制台完整显示,可以尝试缩小控制台窗口或减小层数来查看完整图案。

JAVA学生班级管理系统 源代码 截图

JAVA学生班级管理系统 源代码 截图

一、需求分析1.实现对班级和学生基本资料的录入,包括学生的学号,姓名,性别,所学专业,家庭住址以及出生年月等。

2.能够实现对班级学生基本资料的修改。

3.根据学号对学生资料进行查询。

4.能够删除学生的资料。

二、概要设计根据本次课程设计的目的和以上的问题描述,把该班级管理系统分为五个模块:录入模块(StudentSituation)、查询模块(Inques)、删除模块(Delete)和修改模块(ModifySituation)。

各个模块包括对学生学号,姓名,所学专业,家庭住址,出生日期等信息的操作。

系统的结构图如图一:图1 系统结构图三、总体设计本班级管理系统共有6个java源文件。

类之间的主要关系如下图所示:图2 类之间的主要关系各主类的主要作用如下:1.StudentManager.java该java文件的类负责创建班级学生管理系统的主窗口,该类包含main方法,程序从该类开始执行。

2.StudentStituation.java该文件的类负责创建班级学生管理系统的学生信息录入界面。

3.ModifySituation.java该文件的类负责创建班级学生管理系统的学生基本信息修改界面。

4.Inquest.java该文件的类负责创建班级学生管理系统的学生基本信息查询界面。

5.Delete.java该文件的类负责创建班级学生管理系统的学生信息删除界面。

6.Student.java负责创建存放学生信息的对象。

四、详细设计1.管理系统主窗口1.1成员变量表1-1 主要成员变量1.2方法表1-2 主要方法1.3 界面截图:2.基本信息录入2.1 成员变量表2-1 主要成员变量属性2.2 方法表2-2 主要方法2.3 录入界面截图:3.基本信息查询3.1 成员变量表3-1 主要成员变量属性3.2 方法表3-2 主要方法3.3 查询截图:4.基本信息修改4.1 成员变量表4-1主要成员变量4.2 方法表4-2 主要方法4.3 修改界面截图:5.基本信息删除5.1 成员变量表5-1 主要成员变量5.2 方法表5-2 主要方法5.3 删除界面截图6.学生对象6.1 成员变量表6-1 主要成员变量6.2方法表6-2 主要方法五、总结与展望课程设计是培养学生综合运用所学知识,发现,提出,分析和解决实际问题,锻炼实践能力的重要环节,是对学生实际工作能力的具体训练和考察过程. 本次课程设计虽然很辛苦,实在是受益匪浅。

项目截图及代码

项目截图及代码

1.知识库详情2.知识库增加3.知识库审核开发代码如下:mon;importjava.io.BufferedReader;importjava.io.BufferedWriter;importjava.io.File;importjava.io.FileInputStream;importjava.io.FileNotFoundException;importjava.io.FileOutputStream;importjava.io.FileReader;importjava.io.IOException;importjava.io.InputStream;importjava.io.InputStreamReader;importjava.io.OutputStreamWriter;importjava.io.UnsupportedEncodingException;importjava.nio.channels.FileChannel;importjava.util.ArrayList;importjava.util.List;importjava.util.regex.Matcher;importjava.util.regex.Pattern;public class FileUtils {/*** 文件流读入** @paramfilePath* @return*/public static FileInputStreamreadFile(String filePath) {File file = new File(filePath);FileInputStreamfis = null;try {fis = new FileInputStream(file);} catch (FileNotFoundException e) {throw new RuntimeException(e);}returnfis;}/*** 删除文件** @paramfilePath*/public static void delete(String filePath) {if (filePath == null) {throw new RuntimeException("filePath attribute is required");}File file = new File(filePath);delete(file);}/*** 删除文件** @param file*/public static void delete(File file) {if (file == null) {throw new RuntimeException("file attribute is required");if ((!file.exists()) || (!file.isFile())) {return;}file.delete();}/*** 删除多个文件** @paramfilePath*/public static void deletes(String filePath) {File file = new File(filePath);File[] fileList = file.listFiles();for (File f : fileList) {f.delete();}}/*** 文件是否存在check** @paramfilePath* @return*/public static booleanisExist(String filePath) {if (filePath == null) {throw new RuntimeException("filePath attribute is required");}File file = new File(filePath);return (file.exists()) && (file.isFile());}/*** 文件夹是否存在check** @paramfilePath* @return*/public static booleanisFolderExist(String filePath) {if (filePath == null) {throw new RuntimeException("filePath attribute is required");File file = new File(filePath);returnisFolderExist(file);}/*** 文件夹是否存在check** @param file* @return*/public static booleanisFolderExist(File file) {if (file == null) {throw new RuntimeException("dir attribute is required");}returnfile.exists() &&file.isDirectory();}public static File createFile(String filePath) {File file = new File(filePath);if (!file.exists()) {try {file.createNewFile();} catch (IOException e) {e.printStackTrace();}}return file;}/*** 文件保存** @param stream* @paramfilepath* @paramencodeType*/public static void save(InputStream stream, String filepath,String encodeType) {BufferedReaderbufReader = null;try {bufReader = new BufferedReader(new InputStreamReader(stream,encodeType));} catch (UnsupportedEncodingException e) {throw new RuntimeException(e);}BufferedWriterbufWriter = null;try {FileOutputStreamos = new FileOutputStream(filepath, true);OutputStreamWriterosw = new OutputStreamWriter(os, encodeType);bufWriter = new BufferedWriter(osw);intreadChar = -1;while ((readChar = bufReader.read()) != -1)bufWriter.write(readChar);} catch (IOException e) {throw new RuntimeException(e);} finally {try {if (bufReader != null) {bufReader.close();}if (bufWriter != null)bufWriter.close();} catch (IOException e) {throw new RuntimeException(e);}}}/*** 文件复制** @paramfromFilePath* 源路径* @paramtoFilePath* 目标路径* @return*/public static boolean copy(String fromFilePath, String toFilePath) { if (!isExist(fromFilePath)) {return false;}File in = new File(fromFilePath);File out = new File(toFilePath);FileChannelsourceChannel = null;FileChanneldestinationChannel = null;try {sourceChannel = new FileInputStream(in).getChannel();destinationChannel = new FileOutputStream(out).getChannel();} catch (FileNotFoundException e) {try {if (sourceChannel != null) {sourceChannel.close();}} catch (IOException localIOException1) {throw new RuntimeException(e);}throw new RuntimeException(e);}try {sourceChannel.transferTo(0L, sourceChannel.size(),destinationChannel);sourceChannel.close();destinationChannel.close();} catch (IOException e) {throw new RuntimeException(e);} finally {try {if (sourceChannel != null) {sourceChannel.close();}if (destinationChannel != null)destinationChannel.close();} catch (IOException e) {throw new RuntimeException(e);}}return true;}/*** 创建目录** @paramfilePaht*/public static void maDir(String filePaht) {File file = new File(filePaht);mkDir(file);}/*** 创建目录** @paramdir*/public static void mkDir(File dir) {if (isFolderExist(dir)) {throw new RuntimeException("Unable to create directory as a file already exists with that name: "+ dir.getAbsolutePath());}// 如果存在,不创建if (!dir.exists()) {boolean result = dir.mkdirs();if (!result) {String msg = "Directory " + dir.getAbsolutePath()+ " creation was not successful for an unknown reason";throw new RuntimeException(msg);}}}/*** 获取文件(根据正则表达式检索)** @paramdir* @param pattern* @return*/public static List<File>getFiles(File dir, String pattern) {returngetFiles(dir, pattern, null);}/*** 获取文件** @paramdir* @param pattern* @return*/public static List<File>getFilesRecurse(File dir, String pattern) { returngetFilesRecurse(dir, pattern, null);}/*** 获取除某些文件外列表** @paramdir* @param pattern* @param exclude* @return*/public static List<File>getFiles(File dir, String pattern, File exclude) { returngetFilesRecurse(dir, pile(pattern), exclude, false, newArrayList<File>());}/*** 递归取得文件** @paramdir* @param pattern* @param exclude* @return*/public static List<File>getFilesRecurse(File dir, String pattern,File exclude) {returngetFilesRecurse(dir, pile(pattern), exclude, true, newArrayList<File>());}/*** 读取文件** @param file* @return* @throws Exception*/public static List<String>readLines(File file) throws Exception {if (!file.exists()) {return new ArrayList<String>();}BufferedReader reader = new BufferedReader(new FileReader(file));List<String> results = new ArrayList<String>();try {String line = reader.readLine();while (line != null) {results.add(line);line = reader.readLine();}} finally {reader.close();}return results;}/*** 删除文件夹** @paramdir*/public static void removeDir(File dir) {String[] list = dir.list();if (list == null) {list = new String[0];}for (int i = 0; i <list.length; i++) {String s = list[i];File f = new File(dir, s);if (f.isDirectory())removeDir(f);else {delete(f);}}// 删除文件夹dir.delete();}private static List<File>getFilesRecurse(File dir, Pattern pattern,File exclude, boolean rec, List<File>fileList) {for (File file : dir.listFiles()) {if (file.equals(exclude)) {continue;}if ((file.isDirectory()) && (rec)) {getFilesRecurse(file, pattern, exclude, rec, fileList);} else {Matcher m = pattern.matcher(file.getName());if (m.matches()) {fileList.add(file);}}}returnfileList;}}。

JAVA程序实例(代码和效果图)

JAVA程序实例(代码和效果图)

}
}
public static void main(String args[]){
MenuShow ms=new MenuShow();
}
}
JTextArea jta; JMenuItem jmi1,jmi2,jmi3,jmi4,jmi5,jmi6,jmi7,jmi8; public MenuShow(){
setTitle("菜单演示"); Container con=getContentPane(); BorderLayout bl=new BorderLayout(); JPanel jp=new JPanel(); JMenuBar jmb=new JMenuBar(); setJMenuBar(jmb); JMenu jm1=new JMenu("Color"); jmi1=new JMenuItem("Yellow"); jmi2=new JMenuItem("Orange"); jmi3=new JMenuItem("Pink"); jmi4=new JMenuItem("Blue"); jm1.add(jmi1); jm1.add(jmi2); jm1.add(jmi3); jm1.add(jmi4); JMenu jm2=new JMenu("Style"); jmi5=new JMenuItem("宋体"); jmi6=new JMenuItem("楷体"); jmi7=new JMenuItem("Arial"); jmi8=new JMenuItem("Times New Roman"); jm2.add(jmi5); jm2.add(jmi6); jm2.add(jmi7); jm2.add(jmi8); JMenu jm3=new JMenu("Exit"); jmb.add(jm1); jmb.add(jm2);
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
bar=new JMenuBar();
menu=new JMenu("会员管理");
menu2=new JMenu("图书管理");
menu3=new JMenu("借阅管理");
menu4=new JMenu("罚款管理");
item1=new JMenuItem("添加会员");
item2=new JMenuItem("查询会员");
bar.add(menu);
bar.add(menu2);
bar.add(menu3);
bar.add(menu4);
setJMenuBar(bar);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==item1)
ResultSet rs=stmt.executeQuery(sql);
if(rs.next())
{new mainwin();
this.setVisible(false);
}
else
{
JOptionPane.showMessageDialog(this, "用户名或密码错误!","消息对话",JOptionPane.PLAIN_MESSAGE);
l3=new JLabel("户名");
l4=new JLabel("性别");
l5=new JLabel("说明");
t1=new JTextField(15);
t2=new JTextField(15);
t3=new JTextField(15);
t4=new JTextField(15);
{new deletewin2();
}
if(e.getSource()==item9)
{new searchwin3();
}
if(e.getSource()==item10)
{new searchwin31();
}
if(e.getSource()==item12)
{new searchwin4();
item9=new JMenuItem("借出查询");
item10=new JMenuItem("归还查询");
item12=new JMenuItem("罚款查询");
item1.addActionListener(this);
item2.addActionListener(this);
}
}catch(Exception ee){}
}
}
class mainwin extends JFrame implements ActionListener
{
JMenuBar bar;
JMenu menu;
JMenu menu2;
JMenu menu3;
JMenu menu4;
t5=new JTextField(15);
button=new JButton("添加");
button.addActionListener(this);
button.setBounds(150,260,60,20);
add(l1);
add(t1);
add(l2);
add(t2);
Connection con=DriverManager.getConnection("jdbc:odbc:mydate","sa","");
Statement stmt=con.createStatement();
String sql="select * from guanli where name='"+a+"' and password='"+b+"'" ;
button0.addActionListener(this);
JLabel l11=new JLabel("ID:");
t1=new JTextField(10);
t2=new JPasswordField(10);
button=new JButton("登陆");
button.addActionListener(this);
add(l1);
add(t1);
add(l2);
add(t2);
add(button);
item3.addActionListener(this);
item4.addActionListener(this);
item5.addActionListener(this);
item6.addActionListener(this);
item8.addActionListener(this);
{new writewin();
}
if(e.getSource()==item2)
{new searchwin();
}
if(e.getSource()==item3)
{new deletewin();
}
if(e.getSource()==item4)
{new updatewin();
add(t0);
t0.setBounds(55,20,80,20);
button0=new JButton("查找");
add(button0);
button0.setBounds(140,20,60,20);
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class MYWIND{
public static void main(String args[])
{deluwin a=new deluwin();}
}
if(e.getSource()==item5)
{new searchwin2();
}
if(e.getSource()==item6)
{new updatewin2();
}
{if(e.getSource()==item7)
{new writewin2();
}
if(e.getSource()==item8)
}
}
}
}
class writewin extends JFrame implements ActionListener
{
JLabel l1,l2,l3,l4,l5;
JTextField t1,t2,t3,t4,t5;
JButton button;
writewin()
menu.add(item3);
menu.add(item4);
menu2.add(item5);
menu2.add(item6);
menu2.add(item7);
menu2.add(item8);
menu3.add(item9);
menu3.add(item10);
menu4.add(item12);
item7.addActionListener(this);
item9.addActionListener(this);
item10.addActionListener(this);
item12.addActionListener(this);
menu.add(item1);
menu.add(item2);
JOptionPane.showMessageDialog(this, "添加成功!","消息对话",JOptionPane.WARNING_MESSAGE);
this.setVisible(false);
}
}
class updatewin extends JFrame implements ActionListener
}
class deluwin extends JFrame implements ActionListener
{
JLabel l1,l2;
JTextField t1;
JPasswordField t2;
JButton button;
deluwin()
{ setTitle("登陆");
{ JLabel l0;
JTextField t0;
JButton button0, button;
JTextField password,户名,性别,name;
JTextArea 说明;
updatewin()
{
setLocation(20,30);
JMenuItem item1,item2,item3,item4 ;
JMenuItem item5,item7,item8 ,item6;
JMenuItem item9,item10,item12;
相关文档
最新文档