From f575e555b40629770dcec41eb1ec2f46cc645566 Mon Sep 17 00:00:00 2001
From: JJ
Date: Tue, 21 Mar 2023 17:24:13 -0700
Subject: minor tweaks
---
.idea/.name | 2 +-
.idea/codeStyles/Project.xml | 7 -------
.idea/codeStyles/codeStyleConfig.xml | 2 +-
src/main/ui/BrowserBar.java | 3 ++-
src/main/ui/BrowserCanvas.java | 13 ++++++-------
src/main/ui/BrowserWindow.java | 8 +++++++-
6 files changed, 17 insertions(+), 18 deletions(-)
delete mode 100644 .idea/codeStyles/Project.xml
diff --git a/.idea/.name b/.idea/.name
index 358bba7..577acba 100644
--- a/.idea/.name
+++ b/.idea/.name
@@ -1 +1 @@
-Project-Starter
\ No newline at end of file
+apus
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
deleted file mode 100644
index b3295c5..0000000
--- a/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
index 8f1a3b7..a55e7a1 100644
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
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 tree, Graphics g, Point location) {
+ private void renderHtml(ArrayList 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