diff --git a/.classpath b/.classpath deleted file mode 100644 index ac9ce57c2f4d3a99eb1868e101f3060156474663..0000000000000000000000000000000000000000 --- a/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/.gitignore b/.gitignore deleted file mode 100644 index ae3c1726048cd06b9a143e0376ed46dd9b9a8d53..0000000000000000000000000000000000000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..26d33521af10bcc7fd8cea344038eaaeb78d0ef5 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..639900d13c6182e452e33a3bd638e70a0146c785 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..f1f1d7ca7277b4829a0014e83e976c91ddf127e3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.project b/.project deleted file mode 100644 index b7e8a74e9dd98bfb5b42b70cd6033510d6823948..0000000000000000000000000000000000000000 --- a/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - java2022spring - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index dbc27c5dc60ef7094a88953087ea0294b6c44a38..0000000000000000000000000000000000000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,14 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=17 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=17 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..d8e161da9fd0c22fab97e2f3aa2fd492ff77544e --- /dev/null +++ b/LICENSE @@ -0,0 +1,43 @@ +Academic Free License (“AFL”) v. 3.0 + +This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Academic Free License version 3.0 + +1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + a) to reproduce the Original Work in copies, either alone or as part of a collective work; + b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + c) to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor’s reserved rights and remedies, in this Academic Free License; + d) to perform the Original Work publicly; and + e) to display the Original Work publicly. + +2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + +3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + +4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor’s trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + +5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + +6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + +7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + +8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + +9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including “fair use” or “fair dealing”). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + +10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + +11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + +12) Attorneys’ Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + +13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + +14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + +16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/PaintingBoard/PaintingBoard.iml b/PaintingBoard/PaintingBoard.iml new file mode 100644 index 0000000000000000000000000000000000000000..f9e9a7d3128f17154514562a98c1a3d2121cd0db --- /dev/null +++ b/PaintingBoard/PaintingBoard.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/PaintingBoard/src/PaintingBoard/PaintingBoardCanvas.java b/PaintingBoard/src/PaintingBoard/PaintingBoardCanvas.java new file mode 100644 index 0000000000000000000000000000000000000000..3d30a96f66b269d5724ea8d90d7702fc180c37d0 --- /dev/null +++ b/PaintingBoard/src/PaintingBoard/PaintingBoardCanvas.java @@ -0,0 +1,19 @@ +package PaintingBoard; + +import java.awt.*; + +public class PaintingBoardCanvas extends Canvas { + private Image image = null; + public void setImage(Image image){ + this.image = image; + } + public void paint(Graphics g){ + g.drawImage(image,0,0,null); + } + + //дupdateԽĻ˸ѧġ + public void update(Graphics g){ + paint(g); + } + +} diff --git a/PaintingBoard/src/PaintingBoard/PaintingBoardDemo.java b/PaintingBoard/src/PaintingBoard/PaintingBoardDemo.java new file mode 100644 index 0000000000000000000000000000000000000000..f369aa4de8ee5a6ca86e193a5907ec8c8b2db2bc --- /dev/null +++ b/PaintingBoard/src/PaintingBoard/PaintingBoardDemo.java @@ -0,0 +1,232 @@ +package PaintingBoard; + +import javax.imageio.ImageIO; +import javax.imageio.stream.ImageOutputStream; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +/* +public class PaintingBoardDemo extends JFrame { + + //ƾ + JButton rectangle; + //ɫѡ + JButton colorChoice; + //水ť + JButton save; + //˳ť + JButton quit; + // + JPanel panel; + Canvas canvas; + //Ĭɫ + Color selectColor; + //жϻͼ + String type; + // + int x,y; + //ջͼ + JButton clear; + //Ҽ˵ + PopupMenu penColor; + MenuItem red; + MenuItem green; + MenuItem blue; + Color penColorNow; + + PaintingBoardDemo(){ + setTitle("ͼ"); + setSize(620,550); + setDefaultCloseOperation(EXIT_ON_CLOSE); + setVisible(true); + + penColor = new PopupMenu(); + red = new MenuItem(); + green = new MenuItem(); + blue = new MenuItem(); + penColorNow = Color.BLACK;//ĬΪɫ + + BufferedImage image = new BufferedImage(620,550,BufferedImage.TYPE_INT_RGB); + + + rectangle = new JButton("ƾ"); + add(rectangle); + rectangle.setBounds(1,10,120,30); + + colorChoice = new JButton("ɫѡ"); + add(colorChoice); + colorChoice.setBounds(1,40,120,30); + + save = new JButton(""); + add(save); + save.setBounds(1,70,120,30); + + clear = new JButton(""); + add(clear); + clear.setBounds(1,100,120,30); + + quit = new JButton("˳"); + add(quit); + quit.setBounds(1,130,120,30); + + class MyCanvas extends Canvas {//廭 + @Override + public void paint(Graphics g) { + g.drawImage(image,0,0,null); + } + } + panel = new JPanel(); + panel.setBackground(selectColor.WHITE); + add(panel); + panel.setBounds(125,10,600,600); + setLayout(null); + setVisible(true); + + ActionListener listener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) {//ִеIJ + String actionCommand = e.getActionCommand();//ȡһ + switch(actionCommand){ + case "ɫ": + penColorNow = Color.red; + break; + case "ɫ": + penColorNow = Color.green; + break; + case "ɫ": + penColorNow = Color.blue; + break; + } + } + }; + + red.addActionListener(listener); + green.addActionListener(listener); + blue.addActionListener(listener); + + penColor.add(red); + penColor.add(green); + penColor.add(blue); + + //˳ + quit.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + }); + + //ѡ + colorChoice.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Color color = JColorChooser.showDialog(null,"ѡϲɫ",selectColor); + selectColor = color; + colorChoice.setBackground(selectColor);//ðťıɫѡɫ + } + }); + + // + rectangle.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + type = "rectangle"; + } + }); + + + clear.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + repaint();//ʹrepaintʵһˢµЧ + } + }); + //ڻͼpanel + panel.addMouseListener(new MouseListener() { + + @Override + public void mouseClicked(MouseEvent e) { + + } + + @Override + public void mousePressed(MouseEvent e) { + x = e.getX() + 125; + y = e.getY() + 10; + } + + @Override + public void mouseReleased(MouseEvent e) { + int x1 = e.getX() + 145; + int y1 = e.getY() + 30; + Graphics2D rect = (Graphics2D) getGraphics(); + rect.setColor(selectColor); + if(type.equals("rectangle")){ + rect.drawRect(x,y,x1 - x,y1 - y); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); + + //水ť + //ʹýͼķʽ浱ǰĻ + save.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser chooser = new JFileChooser(); + int count = chooser.showDialog(null,""); + if(count == 0){ + File file = chooser.getSelectedFile(); + ImageOutputStream imageOutputStream = null; + try { + imageOutputStream = ImageIO.createImageOutputStream(file); + Dimension imageSize = panel.getSize(); + int width = (int)imageSize.getWidth(); + int height = (int)imageSize.getHeight(); + //Ϊʹnew Rectangle + Robot robot = new Robot(); + BufferedImage bufferedimage = robot.createScreenCapture(new Rectangle(getBounds().x,getBounds().y,width + 30,height + 30)); + ImageIO.write(bufferedimage,"png",imageOutputStream); + + } catch (IOException ex) { + throw new RuntimeException(ex); + } catch (AWTException ex) { + throw new RuntimeException(ex); + } + } + } + }); + + + + //ұȽϲз + setLocationRelativeTo(null); + //colorChoice.setBackground(selectColor.GRAY);ðɫٸ + } + + public static void main(String[] args) { + new PaintingBoardDemo(); + } + +} + + +//5.17ʹýͼʽͼƬ + + + */ \ No newline at end of file diff --git a/PaintingBoard/src/PaintingBoard/PaintingBoardDemo2.java b/PaintingBoard/src/PaintingBoard/PaintingBoardDemo2.java new file mode 100644 index 0000000000000000000000000000000000000000..6de3ac0a4f9134725fc58d5ac79ca98719506153 --- /dev/null +++ b/PaintingBoard/src/PaintingBoard/PaintingBoardDemo2.java @@ -0,0 +1,154 @@ +package PaintingBoard; + +import javax.imageio.ImageIO; +import javax.imageio.stream.ImageOutputStream; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +/* +public class PaintingBoardDemo2 extends JFrame { + //廭ͼС + JFrame frame = new JFrame("ͼ"); + final int area_Width = 600; + final int area_Height = 600; + //Ҽɫ˵ + PopupMenu penColorMenu = new PopupMenu(); + MenuItem red = new MenuItem("ɫ"); + MenuItem green = new MenuItem("ɫ"); + MenuItem blue = new MenuItem("ɫ"); + //廭Ĭɫ + Color penColorNow = Color.BLACK; + //ͼƬ + BufferedImage image = new BufferedImage(area_Width,area_Height,BufferedImage.TYPE_INT_RGB); + Graphics graphics = image.getGraphics(); + //XY¼϶һε + int preX = -1; + int preY = -1; + + //水ť + JButton save; + JPanel panel; + //ǵĻ + + + PaintingBoardDemo2() { + + + class myCanvas extends Canvas { + @Override + public void paint(Graphics g) { + g.drawImage(image, 0, 0, null); + } + } + + myCanvas drawArea = new myCanvas(); + //ûͼ + drawArea.setPreferredSize(new Dimension(area_Width,area_Height)); + frame.add(drawArea); + frame.setLocation(350,100); + frame.setSize(900,700); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLayout(new FlowLayout()); + frame.setResizable(true); + + graphics.setColor(Color.white); + graphics.fillRect(0,0,area_Width,area_Height); + + JPanel panel = new JPanel(); + panel.setBounds(200,200,200,200); + frame.add(panel); + JButton save = new JButton(""); + panel.add(save); + save.setBounds(10,100,20,20); + + + save.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser chooser = new JFileChooser(); + int count = chooser.showDialog(null,""); + if(count == 0){ + File file = chooser.getSelectedFile(); + ImageOutputStream imageOutputStream = null; + try { + imageOutputStream = ImageIO.createImageOutputStream(file); + Dimension imageSize = drawArea.getSize(); + int width = (int)imageSize.getWidth(); + int height = (int)imageSize.getHeight(); + //Ϊʹnew Rectangle + Robot robot = new Robot(); + BufferedImage bufferedimage = robot.createScreenCapture(new Rectangle(350,100,350 + width,100 + height)); + ImageIO.write(bufferedimage,"png",imageOutputStream); + + } catch (IOException ex) { + throw new RuntimeException(ex); + } catch (AWTException ex) { + throw new RuntimeException(ex); + } + } + } + }); + + + //Ҽ + ActionListener listener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) {//ִеIJ + String actionCommand = e.getActionCommand(); + switch(actionCommand){ + case "ɫ": + penColorNow = Color.red; + break; + case "ɫ": + penColorNow = Color.green; + break; + case "ɫ": + penColorNow = Color.blue; + break; + } + } + }; + + red.addActionListener(listener); + green.addActionListener(listener); + blue.addActionListener(listener); + + penColorMenu.add(red); + penColorMenu.add(green); + penColorMenu.add(blue); + + drawArea.add(penColorMenu); + + drawArea.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + boolean isPopup = e.isPopupTrigger(); + if(isPopup){ + penColorMenu.show(drawArea,e.getX(),e.getY()); + } + + preX = -1; + preY = -1; + } + }); + drawArea.addMouseMotionListener(new MouseMotionAdapter() { + @Override + public void mouseDragged(MouseEvent e) { + if(preX > 0 && preY > 0){ + graphics.setColor(penColorNow); + graphics.drawLine(preX,preY,e.getX(),e.getY()); + } + //¼µĿǰ + preX = e.getX(); + preY = e.getY(); + + drawArea.repaint(); + } + }); + } +} +*/ \ No newline at end of file diff --git a/PaintingBoard/src/PaintingBoard/PaintingBoardDemo3.java b/PaintingBoard/src/PaintingBoard/PaintingBoardDemo3.java new file mode 100644 index 0000000000000000000000000000000000000000..f807a77f3489884e810e2fe9227ea998d02699d8 --- /dev/null +++ b/PaintingBoard/src/PaintingBoard/PaintingBoardDemo3.java @@ -0,0 +1,4 @@ +package PaintingBoard; + + + diff --git a/PaintingBoard/src/PaintingBoard/PaintingBoardPictureFrame.java b/PaintingBoard/src/PaintingBoard/PaintingBoardPictureFrame.java new file mode 100644 index 0000000000000000000000000000000000000000..7086048509cde70e495ce1cd1b602784276e6392 --- /dev/null +++ b/PaintingBoard/src/PaintingBoard/PaintingBoardPictureFrame.java @@ -0,0 +1,779 @@ +package PaintingBoard; + + +import javax.imageio.ImageIO; +import javax.imageio.stream.ImageOutputStream; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.beans.PropertyVetoException; +import java.util.ArrayList; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.undo.*; +import static java.lang.Math.abs; + +public class PaintingBoardPictureFrame extends JFrame { + BufferedImage image1 = new BufferedImage(800,800,BufferedImage.TYPE_3BYTE_BGR); + Graphics gs = image1.getGraphics(); + Graphics2D g = (Graphics2D)gs; + PaintingBoardCanvas canvas1 = new PaintingBoardCanvas(); + //ǰɫͱɫѧģǰɫԵʵɫ + Color forecolor = Color.BLACK; + Color backgroundColor = Color.WHITE; + + ObjectOutputStream output; + ObjectInputStream input; + + int x = -1; + int y = -1; + + int signalX = 30; + int signalY = 30; + int drawX = -1; + int drawY = -1; + int drawX2 = -1; + int drawY2 = -1; + boolean isRubber = false;//Ƥ״̬ + + //boolean isDrawShape = false;//ͼ״̬ + + String shape = "nothing";//ͼѡ + + + JToolBar toolBar; + JButton rubberButton; + JToggleButton slimPenButton; + JToggleButton normalPenButton; + JToggleButton boldPenButton; + JButton backgroudnColorButton; + JButton foreColorButton; + JButton clearButton; + JButton saveButton; + JButton openButton; + JButton undoButton; + + + PopupMenu penColorMenu; + MenuItem red; + MenuItem green; + MenuItem blue; + + //ͼβ˵ + JMenuBar menuBar; + //˵ + JMenu menuShape; + JMenu help; + + JMenu signal; + //˵Ԫ + JMenuItem rectangleItem,circleItem,lineItem,cancleChoice; + JMenuItem helpItem,useItem; + + JMenuItem signalItem,boldChoice,getLocation; + JMenuItem signalFontColorItem; + JMenuItem signalFontStyleItem; + JMenuItem signalFontSizeItem; + + String signalContent = ""; + + int saved = 0;//Ƿ + + int index = 0;//¼һ + + //Shape[] itemList = new Shape[5000]; + + //undo˼·ѧģװеĵ㣬һؾͺ + int [] xStart = new int[10000]; + int [] yStart = new int[10000]; + int [] xEnd = new int[10000]; + int [] yEnd = new int[10000]; + + int [] xStart2 = new int[10000]; + int [] yStart2 = new int[10000]; + int [] xEnd2 = new int[10000]; + int [] yEnd2 = new int[10000]; + int index2 = 0; + + Color myFontColor = Color.GRAY; + + int mySignalFontSize = 35; + int mySignalFontStyle = Font.BOLD; + + + public PaintingBoardPictureFrame(){ + + setResizable(false); + setTitle("ͼ"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(500, 100, 600, 600); + init(); + addListener(); + } + + public void addListener(){ + + boldChoice.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + int boldness = Integer.parseInt(JOptionPane.showInputDialog(null, "ҪĻʴϸǣֻ")); + BasicStroke bs = new BasicStroke(boldness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); + g.setStroke(bs); + }catch (Exception e1){ + //System.out.println("δûȷûʴϸĬֵ"); + JOptionPane.showMessageDialog(null,"δûȷûʴϸһֵ"); + } + }//Ϊûʴϸı + }); + + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + if(saved == 0){ + int n =JOptionPane.showConfirmDialog(null,"δ棬ȷҪ˳","ʾ",JOptionPane.OK_CANCEL_OPTION); + if(n == JOptionPane.YES_OPTION){ + System.exit(0); + } + } + if(saved == 1){ + System.exit(0); + } + } + }); + openButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + openPic(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + }); + + + undoButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + undo(); + canvas1.repaint(); + + + } + }); + + canvas1.addMouseMotionListener(new MouseMotionListener() { + @Override + public void mouseDragged(final MouseEvent e) { + + if(x > 0 && y > 0){ + if(isRubber){ + g.setColor(backgroundColor); + g.fillRect(x,y,10,10); + }else if(shape == "nothing"){ + try { + g.drawLine(x, y, e.getX(), e.getY()); + xStart[index] = x; + yStart[index] = y; + xEnd[index] = e.getX(); + yEnd[index] = e.getY(); + index++; + xStart2[index2] = x; + yStart2[index2] = y; + xEnd2[index2] = e.getX(); + yEnd2[index2] = e.getY(); + index2++; + }catch(Exception e2){ + JOptionPane.showMessageDialog(null, "滭ı̫ˣˣ»"); + } + + } + } + x = e.getX(); + y = e.getY(); + canvas1.repaint(); + saved = 0; + } + + @Override + public void mouseMoved(MouseEvent e) { + if(isRubber) { + setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + }else { + setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + } + + } + }); + + toolBar.addMouseMotionListener(new MouseMotionAdapter() { + @Override + public void mouseMoved(MouseEvent e) { + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + }); + canvas1.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + x = -1; + y = -1; + } + }); + + slimPenButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + setSlimPen();//ñˢ + } + }); + + normalPenButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + setNormalPen(); + } + }); + + boldPenButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + setBoldPen(); + } + + }); + + backgroudnColorButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + setMyCanvasBackgroundColor(); + for (int i = 0; i <= index2; i++) { + g.drawLine(xStart2[i], yStart2[i], xEnd2[i], yEnd2[i]); + canvas1.repaint(); + } + + } + }); + + foreColorButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + setMyCanvasForeColor(); + } + }); + + clearButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + g.setColor(backgroundColor); + g.fillRect(0,0,600,600); + g.setColor(forecolor); + canvas1.repaint(); + for(int i = 0 ;i < index2; i++){ + xStart2[i] = 0; + yStart2[i] = 0; + xEnd2[i] = 0; + yEnd2[i] = 0; + } + } + }); + + rubberButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(rubberButton.getText().equals("Ƥ")){ + isRubber = true; + rubberButton.setText("ͼ"); + }else{ + isRubber = false; + rubberButton.setText("Ƥ"); + g.setColor(forecolor); + } + } + }); + + saveButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + savePic(); + saved = 1; + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + }); + + //ʹ֪ + helpItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(null,"Ļͼʹ˵:\n" + "(1)ʹñ湦ܵʱú.jpg׺\n" + + + "(2)ˮӡϵIJãƤĨȥ\n" + + "(3)ѡƤ֮Ҫлػͼģʽܼ滭\n" + + "(4)ѡˮӡλãǵҪȥԻȡˮӡλãȻٵĿλü" + ); + } + }); + + useItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(null,"ʹü\n" + "(1)ҼԻһԭɫ˵"); + } + }); + + cancleChoice.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + shape = "nothing"; + } + }); + rectangleItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + shape = "rectangle"; + g.setColor(forecolor); + } + }); + + circleItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + shape = "circle"; + g.setColor(forecolor); + } + }); + + lineItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + shape = "line"; + } + }); + + canvas1.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + + } + + @Override + public void mousePressed(MouseEvent e) { + drawX = e.getX(); + drawY = e.getY(); + //System.out.println("ͼ1" + drawX + drawY); + + } + + @Override + public void mouseReleased(MouseEvent e) { + drawX2 = e.getX(); + drawY2 = e.getY(); + //System.out.println("ͼ2"+ drawX2 + drawY2); + if(shape.equals("rectangle")){ + g.drawRect(Math.min(drawX,drawX2),Math.min(drawY,drawY2),Math.abs(drawX2 - drawX),Math.abs(drawY2 - drawY)); + canvas1.repaint(); + //System.out.println("rect"); + + }else if(shape.equals("circle")){ + g.drawOval(Math.min(drawX,drawX2),Math.min(drawY,drawY2),Math.abs(drawX2 - drawX),Math.abs(drawY2 - drawY)); + canvas1.repaint(); + }else if(shape.equals("line")){ + g.drawLine(drawX,drawY,drawX2,drawY2); + canvas1.repaint(); + } + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); + + ActionListener listenerForFast = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) {//ִеIJ + String actionCommand = e.getActionCommand(); + switch(actionCommand){ + case "ɫ": + forecolor = Color.red; + g.setColor(forecolor); + foreColorButton.setBackground(forecolor); + break; + case "ɫ": + forecolor = Color.green; + g.setColor(forecolor); + foreColorButton.setBackground(forecolor); + break; + case "ɫ": + forecolor = Color.blue; + g.setColor(forecolor); + foreColorButton.setBackground(forecolor); + break; + } + } + }; + red.addActionListener(listenerForFast); + green.addActionListener(listenerForFast); + blue.addActionListener(listenerForFast); + + + canvas1.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + boolean isPopup = e.isPopupTrigger(); + if(isPopup){ + penColorMenu.show(canvas1,e.getX(),e.getY()); + } + } + }); + + + signalItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + signalContent = JOptionPane.showInputDialog(PaintingBoardPictureFrame.this,"ӵˮӡ"); + if(signalContent == null){ + signalContent = ""; + } + addSignal(); + } + }); + + getLocation.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + getSignalXY(); + } + }); + + signalFontColorItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + setMySignalFontColor(); + } + }); + + signalFontStyleItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + setMysignalFontStyle(); + } + }); + + signalFontSizeItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + setMysignalFontSize(); + } + }); + + + + } + public void init(){ + g.setColor(backgroundColor); + g.fillRect(0, 0, 800, 800); + g.setColor(forecolor); + canvas1.setImage(image1); + getContentPane().add(canvas1); + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + + + + toolBar = new JToolBar(); + toolBar.setFloatable(false); + getContentPane().add(toolBar,BorderLayout.NORTH); + + + + openButton = new JButton("ͼ"); + toolBar.add(openButton); + saveButton = new JButton(""); + toolBar.add(saveButton); + undoButton = new JButton(""); + toolBar.add(undoButton); + toolBar.addSeparator();//Ӱťָ֮ߵ + + slimPenButton = new JToggleButton("ϸ"); + slimPenButton.setSelected(true);//ĬΪϸ״̬ + toolBar.add(slimPenButton); + + normalPenButton = new JToggleButton(""); + toolBar.add(normalPenButton); + + boldPenButton = new JToggleButton(""); + toolBar.add(boldPenButton); + + ButtonGroup penSizeGroup = new ButtonGroup(); + penSizeGroup.add(slimPenButton); + penSizeGroup.add(normalPenButton); + penSizeGroup.add(boldPenButton); + + toolBar.add(boldPenButton); + toolBar.addSeparator(); + + backgroudnColorButton = new JButton("ɫ"); + toolBar.add(backgroudnColorButton); + + foreColorButton = new JButton("ˢɫ"); + toolBar.add(foreColorButton); + toolBar.addSeparator(); + + clearButton = new JButton(""); + toolBar.add(clearButton); + + rubberButton = new JButton("Ƥ"); + toolBar.add(rubberButton); + + + menuBar = new JMenuBar(); + menuShape = new JMenu("ѡͼ"); + help = new JMenu("ʹð"); + circleItem = new JMenuItem("Բ"); + circleItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK)); + rectangleItem = new JMenuItem(""); + rectangleItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); + lineItem = new JMenuItem("ֱ"); + lineItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK)); + cancleChoice = new JMenuItem("ȡѡ"); + cancleChoice.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK)); + helpItem = new JMenuItem(""); + helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_MASK)); + useItem = new JMenuItem(""); + getLocation = new JMenuItem("ȡˮӡλ"); + signalItem = new JMenuItem("ˮӡ"); + boldChoice = new JMenuItem("ʴϸ"); + signalFontColorItem = new JMenuItem("ˮӡɫ"); + signalFontStyleItem = new JMenuItem("ˮӡʽ"); + signalFontSizeItem = new JMenuItem("ˮӡС"); + signal = new JMenu("Ի"); + menuShape.add(lineItem); + menuShape.add(circleItem); + menuShape.add(rectangleItem); + menuShape.add(cancleChoice); + help.add(helpItem); + help.add(useItem); + menuBar.add(menuShape); + menuBar.add(help); + setJMenuBar(menuBar); + menuBar.add(signal); + signal.add(signalItem); + signal.add(boldChoice); + signal.add(getLocation); + signal.add(signalFontColorItem); + signal.add(signalFontSizeItem); + signal.add(signalFontStyleItem); + + penColorMenu = new PopupMenu(); + red = new MenuItem("ɫ"); + green = new MenuItem("ɫ"); + blue = new MenuItem("ɫ"); + + penColorMenu.add(red); + penColorMenu.add(green); + penColorMenu.add(blue); + + canvas1.add(penColorMenu); + } + + public void setSlimPen(){ + BasicStroke bs = new BasicStroke(1,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER); + g.setStroke(bs); + slimPenButton.setSelected(true); + } + + public void setNormalPen(){ + BasicStroke bs = new BasicStroke(3,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER); + g.setStroke(bs); + normalPenButton.setSelected(true); + } + + public void setBoldPen(){ + BasicStroke bs = new BasicStroke(7,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER); + g.setStroke(bs); + boldPenButton.setSelected(true); + } + + public void setMyCanvasBackgroundColor(){ + Color myCanvasBackgroundColor = null; + myCanvasBackgroundColor = JColorChooser.showDialog(PaintingBoardPictureFrame.this,"ɫѡ",Color.CYAN); + if(myCanvasBackgroundColor != null){ + backgroundColor = myCanvasBackgroundColor; + backgroudnColorButton.setBackground(myCanvasBackgroundColor);//ťóѡɫ + g.setColor(myCanvasBackgroundColor); + g.fillRect(0,0,870,800);//ı䱳ɫʵǻһСպõľνȥ + g.setColor(forecolor);//ѡرˢɫ + canvas1.repaint(); + + } + + } + public void setMyCanvasForeColor(){ + Color myCanvasForeColor = JColorChooser.showDialog(PaintingBoardPictureFrame.this,"ǰɫѡ",Color.CYAN); + if(myCanvasForeColor != null){ + forecolor = myCanvasForeColor; + } + foreColorButton.setBackground(myCanvasForeColor); + g.setColor(forecolor); + } + + public void getSignalXY(){ + canvas1.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + signalX = e.getX(); + signalY = e.getY();//ڼ¼ˮӡλ + } + }); + + } + public void addSignal(){ + if(!"".equals(signalContent.trim())){ + Font font = new Font("",mySignalFontStyle,mySignalFontSize); + g.setFont(font); + g.setColor(myFontColor); + AlphaComposite alphaComposite = AlphaComposite.SrcOver.derive(0.4f);//͸Ч + g.setComposite(alphaComposite); + g.drawString(signalContent,signalX,signalY); + //System.out.println(signalY); + canvas1.repaint(); + alphaComposite = AlphaComposite.SrcOver.derive(1f);//ûȥ + g.setComposite(alphaComposite); + g.setColor(forecolor); + } + } + + void undo(){ + if (index >= 1) { + for(int i = 10;i > 2;i--) { + g.drawLine(xStart[index], yStart[index], xEnd[index], yEnd[index]); + index--; + if(index<0){ + index = 0; + break; + } + } + } + else + return; + } + + + public String savePic() throws IOException{ + //һҪϵ˼·˶ǽöдϢȡҿǵԴ롣 + //ҵ¿˿ٱ뷨оܷˮƽεѧϰһ»ʵҪ󣬶DZһŽͼ + try { + Dimension imagesize = this.canvas1.getSize(); + BufferedImage image = new BufferedImage(imagesize.width, imagesize.height, BufferedImage.TYPE_INT_RGB); + + Graphics2D graphics = image.createGraphics(); + this.canvas1.paint(graphics); + graphics.dispose(); + //ͼƬС + Image newImage = image.getScaledInstance(800, 800, Image.SCALE_SMOOTH); + BufferedImage myImage = new BufferedImage(800, 800, BufferedImage.TYPE_INT_RGB); + Graphics graphics1 = myImage.getGraphics(); + graphics1.drawImage(newImage, 0, 0, null); + graphics1.dispose(); + + JFileChooser chooser = new JFileChooser(); + chooser.showDialog(null, "");//һѡļеĽ + String path2 = chooser.getSelectedFile().getPath(); + //String path = "D:\\javawork2022\\java2022spring\\PaintingBoard\\src\\sources\\1.jpg"; + File f = new File(path2); + if (!f.exists()) { + f.createNewFile(); + System.out.println(1); + ImageIO.write(myImage, "jpg", f); + } else if (f.exists()) { + int isCover = JOptionPane.showConfirmDialog(null, "ͬͼƬѴڣ"); + if (isCover == JOptionPane.YES_OPTION) { + ImageIO.write(myImage, "jpg", f); + } + } + }catch (Exception e){ + System.out.println("δñ·"); + } + + + + return null; + } + + public String openPic() throws IOException { + //ҪһͼƬǷֺ鷳ΪҪcanvasĻҪ»ʲôģϿҲˣͼʲôʲôػ + //ͬˮƽԭǾʹԭǸѧĹ˼һµJFrameǸĿͼƬͺ + try{ + JFileChooser chooser = new JFileChooser(); + FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG","jpg"); + chooser.setFileFilter(filter); + chooser.showDialog(null,"");//һѡļеĽ + String path3 = chooser.getSelectedFile().getPath(); + JFrame showFrame=new JFrame("οͼ"); + showFrame.setBounds(400, 200, 500, 300); + showFrame.setVisible(true); + ImageIcon img=new ImageIcon(path3); + + JLabel backgroundPic=new JLabel(img); + showFrame.getLayeredPane().add(backgroundPic); + backgroundPic.setBounds(0, 0, img.getIconWidth(), img.getIconHeight()); + showFrame.add(backgroundPic); + + }catch (Exception e){ + System.out.println("δôĿļ·"); + } + return null; + } + + public void setMySignalFontColor(){ + myFontColor = JColorChooser.showDialog(PaintingBoardPictureFrame.this,"ˮӡɫѡ",Color.CYAN); + } + + public void setMysignalFontStyle(){ + try { + mySignalFontStyle = (int) Integer.parseInt(JOptionPane.showInputDialog(null, "1Ϊ\n" + "2Ϊб\n" + "0Ϊ")); + if (mySignalFontStyle == 1) + mySignalFontStyle = 1; + else if (mySignalFontStyle == 2) + mySignalFontStyle = 2; + else if (mySignalFontStyle == 0) + mySignalFontStyle = 0; + else { + mySignalFontStyle = 0; + JOptionPane.showMessageDialog(null, "δȷˮӡ壬Ĭֵ"); + } + }catch(Exception e){ + JOptionPane.showMessageDialog(null, "δȷˮӡ壬Ĭֵ"); + mySignalFontStyle = 0; + } + + + + } + + public void setMysignalFontSize(){ + try { + mySignalFontSize = (int) Integer.parseInt(JOptionPane.showInputDialog(null, "ҪˮӡС(ֻܽ)")); + }catch (Exception e){ + JOptionPane.showMessageDialog(null, "δˮӡСĬֵ"); + } + if(mySignalFontSize < 0) { + JOptionPane.showMessageDialog(null, "δȷˮӡСĬֵ"); + mySignalFontSize = 35; + }if(mySignalFontSize > 100){ + JOptionPane.showMessageDialog(null, "ˮӡ̫ˣĬֵ"); + mySignalFontSize = 35; + } + } + +} diff --git a/PaintingBoard/src/PaintingBoard/startPaintingBoard.java b/PaintingBoard/src/PaintingBoard/startPaintingBoard.java new file mode 100644 index 0000000000000000000000000000000000000000..25debfdb54bf72dedcaf2ff14470f3784b82c545 --- /dev/null +++ b/PaintingBoard/src/PaintingBoard/startPaintingBoard.java @@ -0,0 +1,17 @@ +package PaintingBoard; +import javax.swing.*; +import java.awt.*; + +public class startPaintingBoard { + public static void main(String[] args) { + PaintingBoardPictureFrame frame = new PaintingBoardPictureFrame(); + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { + e.printStackTrace(); + }; + //ѧģܰǸܸŵĽ滻ִ + frame.setVisible(true); + } +} + diff --git a/PaintingBoard/src/PaintingBoard/unusedCodes.java b/PaintingBoard/src/PaintingBoard/unusedCodes.java new file mode 100644 index 0000000000000000000000000000000000000000..d4bde99b3c537a391b5cc33b836ed1330f60486d --- /dev/null +++ b/PaintingBoard/src/PaintingBoard/unusedCodes.java @@ -0,0 +1,62 @@ +package PaintingBoard; + +//public class unusedCodes { +//} +/* +ӵѡ򣬵DzҪ״̬ + //ͼѡ + JCheckBox checkbox1,checkBox2; + //ѡť + JRadioButton radioRectangel,radioCircle; + // + ButtonGroup groupShape; + + + checkbox1 = new JCheckBox(""); + checkBox2 = new JCheckBox("Բ"); + groupShape = new ButtonGroup(); + radioRectangel = new JRadioButton(""); + radioCircle = new JRadioButton("Բ"); + groupShape.add(radioCircle); + groupShape.add(radioRectangel); + add(checkbox1); + add(checkBox2); + add(radioCircle); + add(radioRectangel); + radioRectangel.setBounds(1,130,120,30); + radioCircle.setBounds(1,160,120,30); + */ +/* +˵ҲҪ״̬ + //ͼβ˵ + JMenuBar menuBar; + //˵ + JMenu menuShape; + //˵Ԫ + JMenuItem rectangleItem,circleItem; + + + menuBar = new JMenuBar(); + menuShape = new JMenu("ѡͼ"); + circleItem = new JMenuItem("Բ"); + rectangleItem = new JMenuItem(""); + menuShape.add(circleItem); + menuShape.add(rectangleItem); + menuBar.add(menuShape); + setJMenuBar(menuBar); + + showPictureButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + boolean isVisable = jfshow.isVisible(); + if(!isVisable){ + showPictureButton.setText("ؽѧ"); + jfshow.setVisible(true); + }else{ + showPictureButton.setText("չѧ"); + jfshow.setVisible(false); + } + } + }); + */ \ No newline at end of file diff --git a/PaintingBoard/src/imageIcon.jpg b/PaintingBoard/src/imageIcon.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c9f8c237c198264ea9a15d6acd912109fa4d2af0 Binary files /dev/null and b/PaintingBoard/src/imageIcon.jpg differ diff --git a/PaintingBoard/src/sources/1.jpg b/PaintingBoard/src/sources/1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1b18e8eaf030903e71591d74d7bfc3496e6e50cb Binary files /dev/null and b/PaintingBoard/src/sources/1.jpg differ diff --git a/PaintingBoard/src/sources/horse.jpg b/PaintingBoard/src/sources/horse.jpg new file mode 100644 index 0000000000000000000000000000000000000000..48a3c86c37eb5922efea119f932786243990bcea Binary files /dev/null and b/PaintingBoard/src/sources/horse.jpg differ diff --git a/PaintingBoard/src/sources/picture28.jpg b/PaintingBoard/src/sources/picture28.jpg new file mode 100644 index 0000000000000000000000000000000000000000..44284a7607a81e8da0965893cfbe1ec8068c8ae9 Binary files /dev/null and b/PaintingBoard/src/sources/picture28.jpg differ diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..af719d029f515290b1f71ad2b8e0a1847a52197d --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# 0321_luozhen_paintingBoard + +#### 介绍 +2022春,《Java面向对象程序设计实验》设计性实验 +只是一个课程作业 + +#### 软件架构 +软件架构说明 + + +#### 安装教程 + +1. xxxx +2. xxxx +3. xxxx + +#### 使用说明 + +1. xxxx +2. xxxx +3. xxxx + +#### 参与贡献 + +1. Fork 本仓库 +2. 新建 Feat_xxx 分支 +3. 提交代码 +4. 新建 Pull Request + + +#### 特技 + +1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md +2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) +3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 +4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 +5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) +6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/java2022spring.iml b/java2022spring.iml new file mode 100644 index 0000000000000000000000000000000000000000..9a5cfcef63aeb6c73691f546497af36a69541a4e --- /dev/null +++ b/java2022spring.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardCanvas.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardCanvas.class new file mode 100644 index 0000000000000000000000000000000000000000..da036fe9368180fd59d2315daaf040adc8251d30 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardCanvas.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$1.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$1.class new file mode 100644 index 0000000000000000000000000000000000000000..e80b6506deb104fb685a235dca19e4508cf8839f Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$1.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$10.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$10.class new file mode 100644 index 0000000000000000000000000000000000000000..448e056f789bbea5a76451e38d58cd2f896d6eab Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$10.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$11.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$11.class new file mode 100644 index 0000000000000000000000000000000000000000..4af09c014a8171384f241fc99a16c668aa6992f0 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$11.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$12.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$12.class new file mode 100644 index 0000000000000000000000000000000000000000..1aa9350e13c62465ef1288967c0686af8ad650a0 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$12.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$13.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$13.class new file mode 100644 index 0000000000000000000000000000000000000000..48a1a023b8d7ba9bd1373c0eeb7e2444b4803dd8 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$13.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$14.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$14.class new file mode 100644 index 0000000000000000000000000000000000000000..ec6602aac2c3ad42ae78f5e3c19d45326dd02862 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$14.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$15.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$15.class new file mode 100644 index 0000000000000000000000000000000000000000..0c59971e20ddf7ab0b79e57617de7458b4abbd35 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$15.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$16.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$16.class new file mode 100644 index 0000000000000000000000000000000000000000..5e665d05860d07d0f4825dc80e34e1bf2c1a98f9 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$16.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$17.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$17.class new file mode 100644 index 0000000000000000000000000000000000000000..5a790fbf6545184702067015e4e687c613d2660e Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$17.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$18.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$18.class new file mode 100644 index 0000000000000000000000000000000000000000..6163ff43a1d0b366a95fc542a3408f0eba6e52ac Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$18.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$19.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$19.class new file mode 100644 index 0000000000000000000000000000000000000000..bae10223a32bc3868c81ffc47c4ff14acaf54a18 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$19.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$2.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$2.class new file mode 100644 index 0000000000000000000000000000000000000000..4cdc2cd4a0f6f1ca467782a1fb41b37a60cdd9c0 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$2.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$3.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$3.class new file mode 100644 index 0000000000000000000000000000000000000000..d5e8ed263ed2a4b8c28132d1a6188c874dd670e1 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$3.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$4.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$4.class new file mode 100644 index 0000000000000000000000000000000000000000..985f5a95919db8d500a8e37cde548dc7a68da612 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$4.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$5.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$5.class new file mode 100644 index 0000000000000000000000000000000000000000..426132b3b3c49715cd21161cb00040a4f462495e Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$5.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$6.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$6.class new file mode 100644 index 0000000000000000000000000000000000000000..a9ae996bb6eded243c1f33af805d4e07251bf6d4 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$6.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$7.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$7.class new file mode 100644 index 0000000000000000000000000000000000000000..0a0fe23799ee18d9fa25a7690f8c10ba7b2639d5 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$7.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$8.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$8.class new file mode 100644 index 0000000000000000000000000000000000000000..b829d5d0d675252c51c73805c6cb2b7ab94e8950 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$8.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$9.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$9.class new file mode 100644 index 0000000000000000000000000000000000000000..02e8f115c532319e8d4df5576a6bf8067027522e Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame$9.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame.class b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame.class new file mode 100644 index 0000000000000000000000000000000000000000..329f202503e359e32a32c41648e75afaa739e242 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/PaintingBoardPictureFrame.class differ diff --git a/out/production/PaintingBoard/PaintingBoard/startPaintingBoard.class b/out/production/PaintingBoard/PaintingBoard/startPaintingBoard.class new file mode 100644 index 0000000000000000000000000000000000000000..949711e1e875b77cdefb8275c5713861035e2f53 Binary files /dev/null and b/out/production/PaintingBoard/PaintingBoard/startPaintingBoard.class differ diff --git a/out/production/PaintingBoard/imageIcon.jpg b/out/production/PaintingBoard/imageIcon.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c9f8c237c198264ea9a15d6acd912109fa4d2af0 Binary files /dev/null and b/out/production/PaintingBoard/imageIcon.jpg differ diff --git a/readme.md b/readme.md deleted file mode 100644 index 4af16add33b576d095308a1888db35774618715d..0000000000000000000000000000000000000000 --- a/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -# ѧ -0103 \ No newline at end of file diff --git a/src/java2022spring/Test.java b/src/java2022spring/Test.java deleted file mode 100644 index 24deb29bfc0e5f50fdedcd21b504e77b529d48b6..0000000000000000000000000000000000000000 --- a/src/java2022spring/Test.java +++ /dev/null @@ -1,7 +0,0 @@ -package java2022spring; - -public class Test { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -}