summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/TabbedDisplayPanel.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/TabbedDisplayPanel.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/TabbedDisplayPanel.java')
-rw-r--r--NET/worlds/scape/TabbedDisplayPanel.java98
1 files changed, 98 insertions, 0 deletions
diff --git a/NET/worlds/scape/TabbedDisplayPanel.java b/NET/worlds/scape/TabbedDisplayPanel.java
new file mode 100644
index 0000000..c5b99f8
--- /dev/null
+++ b/NET/worlds/scape/TabbedDisplayPanel.java
@@ -0,0 +1,98 @@
+package NET.worlds.scape;
+
+import java.awt.CardLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Panel;
+import java.awt.Point;
+import java.util.Vector;
+
+class TabbedDisplayPanel extends Panel {
+ private int count;
+ private Vector cards = new Vector();
+ private Vector cardNames = new Vector();
+
+ TabbedDisplayPanel() {
+ this.setLayout(new CardLayout());
+ }
+
+ void addItem(Component c) {
+ this.insertItem(this.cards.size(), c);
+ }
+
+ void insertItem(int index, Component c) {
+ String cardName = "" + this.count++;
+ this.cardNames.insertElementAt(cardName, index);
+ this.cards.insertElementAt(c, index);
+ this.add(cardName, c);
+ this.validate();
+ this.repaint();
+ }
+
+ void removeItem(int index) {
+ this.remove((Component)this.cards.elementAt(index));
+ this.cards.removeElementAt(index);
+ this.cardNames.removeElementAt(index);
+ }
+
+ @Override
+ public Component getComponent(int index) {
+ return (Component)this.cards.elementAt(index);
+ }
+
+ void setChoice(int index) {
+ ((CardLayout)this.getLayout()).show(this, (String)this.cardNames.elementAt(index));
+ }
+
+ @Override
+ public Insets insets() {
+ return new Insets(0, 2, 2, 0);
+ }
+
+ @Override
+ public void paint(Graphics g) {
+ g.setColor(this.getBackground());
+ if (this.cards.size() != 0) {
+ Dimension size = this.size();
+ vLine(g, 1, 0, size.height);
+ g.setColor(this.getBackground().brighter());
+ vLine(g, 0, 0, size.height - 2);
+ g.setColor(this.getBackground().darker());
+ hLine(g, 0, size.height - 1, size.width - 1);
+ vLine(g, size.width - 1, size.height - 1, 0);
+ hLine(g, 1, size.height - 2, size.width - 2);
+ vLine(g, size.width - 2, size.height - 2, 0);
+ } else {
+ g.fillRect(0, 0, this.size().width, this.size().height);
+ }
+ }
+
+ private static void vLine(Graphics g, int x1, int y1, int y2) {
+ g.drawLine(x1, y1, x1, y2);
+ }
+
+ private static void hLine(Graphics g, int x1, int y1, int x2) {
+ g.drawLine(x1, y1, x2, y1);
+ }
+
+ @Override
+ public Component locate(int x, int y) {
+ if (!this.inside(x, y)) {
+ return null;
+ } else {
+ int n = this.countComponents();
+
+ for (int i = 0; i < n; i++) {
+ Component c = this.getComponent(i);
+ Point loc = c.location();
+ if (c != null && c.isVisible() && c.inside(x - loc.x, y - loc.y)) {
+ return c;
+ }
+ }
+
+ return this;
+ }
+ }
+}