From f575e555b40629770dcec41eb1ec2f46cc645566 Mon Sep 17 00:00:00 2001
From: JJ
Date: Tue, 21 Mar 2023 17:24:13 -0700
Subject: minor tweaks

---
 src/main/ui/BrowserBar.java    |  3 ++-
 src/main/ui/BrowserCanvas.java | 13 ++++++-------
 src/main/ui/BrowserWindow.java |  8 +++++++-
 3 files changed, 15 insertions(+), 9 deletions(-)

(limited to 'src/main')

diff --git a/src/main/ui/BrowserBar.java b/src/main/ui/BrowserBar.java
index 8026e49..158bf3c 100644
--- a/src/main/ui/BrowserBar.java
+++ b/src/main/ui/BrowserBar.java
@@ -23,7 +23,7 @@ public class BrowserBar extends JToolBar {
         tabButton.addActionListener(toggleTabMenu());
         add(tabButton);
 
-        uriInput = new JTextField();
+        uriInput = new JTextField(100);
         add(uriInput);
 
         openUriButton = new JButton("Go");
@@ -39,6 +39,7 @@ public class BrowserBar extends JToolBar {
         };
     }
 
+    // todo: fix this pretty awful code
     public void addTab(String tab) {
         JToggleButton tabButton = new JToggleButton(tab);
 
diff --git a/src/main/ui/BrowserCanvas.java b/src/main/ui/BrowserCanvas.java
index cde894f..534fe91 100644
--- a/src/main/ui/BrowserCanvas.java
+++ b/src/main/ui/BrowserCanvas.java
@@ -19,22 +19,21 @@ public class BrowserCanvas extends JPanel {
     @Override
     public void paintComponent(Graphics g) {
         super.paintComponent(g);
-        Point location = new Point(10, 20); // we need a mutable reference
         g.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
         g.setColor(Color.WHITE);
-        g.drawString("X", location.x, location.y);
-        renderHtml(this.currentLayout.children, g, location);
+        renderHtml(this.currentLayout.children, g);
     }
 
-    private void renderHtml(ArrayList<Layout> tree, Graphics g, Point location) {
+    private void renderHtml(ArrayList<Layout> tree, Graphics g) {
         for (Layout layout : tree) {
             g.setColor(new Color((int)(Math.random() * 0x1000000)));
             g.drawRect(layout.location.x, layout.location.y, layout.dimension.width, layout.dimension.height);
             g.setColor(Color.WHITE);
-            if (layout.associatedNode instanceof TextNode) {
-                g.drawString(layout.associatedNode.data(), layout.location.x, layout.location.y + layout.dimension.height - 5);
+
+            if (layout.associatedNode instanceof TextNode t) {
+                g.drawString(t.text(), layout.location.x, layout.location.y + layout.dimension.height - 5);
             } else {
-                renderHtml(layout.children, g, location);
+                renderHtml(layout.children, g);
             }
         }
     }
diff --git a/src/main/ui/BrowserWindow.java b/src/main/ui/BrowserWindow.java
index 28d0b13..d774a8f 100644
--- a/src/main/ui/BrowserWindow.java
+++ b/src/main/ui/BrowserWindow.java
@@ -19,8 +19,14 @@ public class BrowserWindow extends JFrame {
 
     public BrowserWindow() {
         super("apus");
-        state = new BrowserState(new ArrayDeque<>(), "");
 
+        try {
+            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        state = new BrowserState(new ArrayDeque<>(), "");
         canvas = new BrowserCanvas(new ArrayList<>());
         browserBar = new BrowserBar(this);
         getContentPane().add(browserBar, BorderLayout.SOUTH);
-- 
cgit v1.2.3-70-g09d2