From 025629b0f454842618e211dd8e26a31d1ffd263c Mon Sep 17 00:00:00 2001 From: Hai HoDac <hhodac@student.unimelb.edu.au> Date: Thu, 24 Oct 2019 23:02:26 +1100 Subject: [PATCH] fixed GUI layout fixed new button bug --- src/GUI/DrawingArea.java | 2 ++ src/GUI/PaintGUI.java | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/GUI/DrawingArea.java b/src/GUI/DrawingArea.java index 4df0903..570ad5b 100644 --- a/src/GUI/DrawingArea.java +++ b/src/GUI/DrawingArea.java @@ -94,6 +94,8 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis public void clear() { image = new BufferedImage(AREA_WIDTH, AREA_HEIGHT, BufferedImage.TYPE_INT_ARGB); + g2 = (Graphics2D) image.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); repaint(); } diff --git a/src/GUI/PaintGUI.java b/src/GUI/PaintGUI.java index 78265a9..9cfdfd9 100644 --- a/src/GUI/PaintGUI.java +++ b/src/GUI/PaintGUI.java @@ -1,7 +1,6 @@ package GUI; import client.Client; -import remote.IDrawingUpdate; import javax.imageio.ImageIO; import javax.swing.*; @@ -107,7 +106,7 @@ public class PaintGUI extends JPanel { // setFontBtn = new JButton("Font"); // setFontBtn.addActionListener(actionListener); textInput = new JTextField("Text here."); - textInput.setColumns(8); + textInput.setColumns(13); textInput.addFocusListener(focusListener); // textInput.setVisible(false); textSize = new JTextField("12"); @@ -409,7 +408,13 @@ public class PaintGUI extends JPanel { private void setTextDetail() { String textString = textInput.getText(); - int size = Integer.parseInt(textSize.getText()); + int size = 12; // default + if (!textSize.getText().isEmpty()) { + size = Integer.parseInt(textSize.getText()); + } + else { + textSize.setText(Integer.toString(size)); + } drawingArea.setModeText(textString, size); } -- GitLab