Skip to content
Snippets Groups Projects
Select Git revision
  • 2d99e3581a6ca0af76d8328431fe5f970c6c8c3c
  • master default protected
  • hai
  • isaac
  • CheHao
  • Eldar
  • mpriymak
  • master-before-merging-with-hai
  • master-before-merging-with-isaac
  • rmi-working-before-merging-with-isaac
  • all-code-merged-by-hai-v1
11 results

PaintGUI.java

Blame
  • Forked from Ho Dac Hai / COMP90015-DSAss2-InfinityMonkeys-remaster
    Source project has a limited visibility.
    PaintGUI.java 14.88 KiB
    package GUI;
    
    import client.Client;
    import remote.IDrawingUpdate;
    
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.filechooser.FileFilter;
    import javax.swing.filechooser.FileNameExtensionFilter;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusListener;
    import java.awt.image.BufferedImage;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.IOException;
    import java.rmi.RemoteException;
    
    public class PaintGUI extends JPanel {
    
        Client client;
        DrawingArea drawingArea;
    
        String[] shapes = {"Freehand", "Line", "Circle", "Rectangle", "Oval", "Eraser", "Text"};
        String[] strokes = {"Thin", "Medium", "Thick"};
        String[] eraserSizes = {"Small", "Medium", "Large"};
        JFrame frame;
        JButton clearBtn, newBtn, openBtn, saveBtn, saveAsBtn;
        JButton freehandBtn, lineBtn, circleBtn, rectBtn, ovalBtn, eraserBtn, textBtn;
        JButton colorPaletteBtn, setFontBtn;
        JTextField textInput, textSize;
        JComboBox strokeOptions;
        JComboBox eraserSizeOptions;
    
        String filePath = "";
        Color currentColor = Color.BLACK;
    
        JPanel global = new JPanel();
        JPanel toolbox = new JPanel();
        JPanel toolbox1 = new JPanel();
        JPanel toolbox2 = new JPanel();
        JPanel fileControl = new JPanel();
        JFileChooser fileChooser= new JFileChooser();
    
        /// GUI setup ///
        public PaintGUI(Client client) {
    
            this.client = client;
    
    /// Main drawing area ///
            drawingArea = new DrawingArea(client);
    //        drawingArea.setPreferredSize(new Dimension(600, 620));
    
    /// Set up main frame and container ///
            global.setLayout(new BorderLayout());
            toolbox.setLayout(new BorderLayout());
    
            /// Set up button icons ///
            try {
                String path = System.getProperty("user.dir");
                System.out.println(path);
                File palettePic = new File(path + "/src/GUI/icon/palette.png");
                File freehandPic = new File(path + "/src/GUI/icon/freehand.png");
                File linePic = new File(path + "/src/GUI/icon/line.png");
                File circlePic = new File(path + "/src/GUI/icon/circle.png");
                File rectPic = new File(path + "/src/GUI/icon/rectangle.png");
                File ovalPic = new File(path + "/src/GUI/icon/oval.png");
                File eraserPic = new File(path + "/src/GUI/icon/eraser.png");