aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJJ2023-03-22 00:24:13 +0000
committerJJ2023-03-22 00:24:13 +0000
commitf575e555b40629770dcec41eb1ec2f46cc645566 (patch)
tree57ea914e05101a8e985552d3f87aadc4d1b602bf
parent595853ad76bbebf74a9a737870d5a89fb9f21f55 (diff)
minor tweaks
-rw-r--r--.idea/.name2
-rw-r--r--.idea/codeStyles/Project.xml7
-rw-r--r--.idea/codeStyles/codeStyleConfig.xml2
-rw-r--r--src/main/ui/BrowserBar.java3
-rw-r--r--src/main/ui/BrowserCanvas.java13
-rw-r--r--src/main/ui/BrowserWindow.java8
6 files changed, 17 insertions, 18 deletions
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 @@
-<component name="ProjectCodeStyleConfiguration">
- <code_scheme name="Project" version="173">
- <XML>
- <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
- </XML>
- </code_scheme>
-</component> \ 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 @@
<component name="ProjectCodeStyleConfiguration">
<state>
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component> \ 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<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);