• 大小: 73KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-24
  • 语言: Java
  • 标签: javafx  画板  

资源简介

使用javafx开发的画板程序,类似于Windows上的画图程序,但所画的图形能够拖动,图形能够保存

资源截图

代码片段和文件信息

package MyPaint;


import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextArea;
import javafx.scene.effect.Blend;
import javafx.scene.effect.Bloom;
import javafx.scene.effect.BoxBlur;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.effect.Glow;
import javafx.scene.effect.InnerShadow;
import javafx.scene.effect.Lighting;
import javafx.scene.effect.Motionblur;
import javafx.scene.effect.SepiaTone;
import javafx.scene.effect.Shadow;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Shape;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
import javafx.stage.Stagestyle;

import MyPaint.ToolsPane;
import MyPaint.winattr;
import MyPaint.WRobject2File;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;

import MyPaint.MyCanvas;

public class Main extends Application{
static MyCanvas canvas;
static ArrayList allShapeChosed;
@SuppressWarnings(“static-access“)
@Override
public void start(Stage stage) throws Exception {
// TODO Auto-generated method stub

initStage(stage);

VBox mainPane = new VBox();
Scene mainScene = new Scene(mainPane stage.getWidth() stage.getHeight());
stage.setScene(mainScene);

initMainPane(mainPane stage);

MenuBar menuBar = this.createMenuBar(stage);
mainPane.getChildren().add(menuBar);
mainPane.setMargin(menuBar new Insets(5555));


ToolsPane toolsBar = this.createToolsBar(stage);
mainPane.getChildren().add(toolsBar);
mainPane.setMargin(toolsBar new Insets(5555));

canvas = this.createMyCanvas(stage toolsBar);
toolsBar.setCanvas(canvas);
mainPane.getChildren().add(canvas);
mainPane.setMargin(canvas new Insets(5515));

TextArea info = this.canvas.getCanvasInfoLabel();
mainPane.getChildren().add(info);
mainPane.setMargin(info new Insets(1555));


mainPane.setonkeypressed(e->{
//this.canvas.deleteChosedShapes();
if ( e.getCode() == KeyCode.A) {
System.out.println(“del“);
}
});

//stage.setAlwaysOnTop(true);
stage.show();

}

//创建菜单栏
public MenuBar createMenuBar(Stage stage) {
MenuBar menubar = new MenuBar();
//将菜单栏的宽和舞台绑定
men

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-22 16:25  Paint\
     文件        2262  2018-12-22 16:25  Paint\.classpath
     文件         381  2018-12-05 15:27  Paint\.project
     目录           0  2018-12-05 15:27  Paint\.settings\
     文件         592  2018-12-05 15:28  Paint\.settings\org.eclipse.jdt.core.prefs
     目录           0  2018-12-22 16:25  Paint\bin\
     目录           0  2018-12-22 16:47  Paint\bin\MyPaint\
     文件        1123  2018-12-22 16:29  Paint\bin\MyPaint\Buttonstyle.class
     文件         574  2018-12-22 16:49  Paint\bin\MyPaint\Copy.class
     文件       10838  2018-12-22 18:34  Paint\bin\MyPaint\Main.class
     文件       14483  2018-12-22 18:33  Paint\bin\MyPaint\MyCanvas.class
     文件        4072  2018-12-22 16:49  Paint\bin\MyPaint\MyCircle.class
     文件        4395  2018-12-22 16:49  Paint\bin\MyPaint\MyEllipse.class
     文件        4838  2018-12-22 16:49  Paint\bin\MyPaint\MyPolygon.class
     文件        4870  2018-12-22 16:49  Paint\bin\MyPaint\MyRectangle.class
     文件         613  2018-12-22 16:49  Paint\bin\MyPaint\MySquare.class
     文件        4079  2018-12-22 16:49  Paint\bin\MyPaint\MyStraitLine.class
     文件        4726  2018-12-22 16:49  Paint\bin\MyPaint\MyText.class
     文件         113  2018-12-22 16:25  Paint\bin\MyPaint\package-info.class
     文件       15914  2018-12-22 18:06  Paint\bin\MyPaint\ToolsPane.class
     文件         949  2018-12-22 16:29  Paint\bin\MyPaint\winattr.class
     文件        3104  2018-12-22 16:29  Paint\bin\MyPaint\WRobject2File.class
     目录           0  2018-12-22 16:36  Paint\resources\
     文件         815  2018-12-20 02:09  Paint\resources\circle_16px.png
     文件         799  2018-12-20 02:09  Paint\resources\ellipse_16px.png
     文件         857  2018-12-20 02:09  Paint\resources\exit_16px.png
     文件        1033  2018-12-20 02:09  Paint\resources\file_24px.png
     文件        1053  2018-12-22 10:23  Paint\resources\information_24px.png
     文件         831  2018-12-20 02:09  Paint\resources\line_10px.png
     文件         837  2018-12-20 02:09  Paint\resources\line_13px.png
     文件         821  2018-12-20 02:09  Paint\resources\line_16px.png
............此处省略21个文件信息

评论

共有 条评论