From 4fd53b91e102a797e9f3a3b139852c7e51a6027f Mon Sep 17 00:00:00 2001 From: Date: Wed, 13 Aug 2008 20:33:55 +0000 Subject: [PATCH] Show different backgrounds for different disks while prototyping --- .../applecommander/ui/swing/DiskExplorer.java | 11 ++++++++++- .../ui/swing/SwingAppleCommander.java | 13 ++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/com/webcodepro/applecommander/ui/swing/DiskExplorer.java b/src/com/webcodepro/applecommander/ui/swing/DiskExplorer.java index b0f7c6d..8f356c3 100644 --- a/src/com/webcodepro/applecommander/ui/swing/DiskExplorer.java +++ b/src/com/webcodepro/applecommander/ui/swing/DiskExplorer.java @@ -1,15 +1,24 @@ package com.webcodepro.applecommander.ui.swing; import java.awt.Color; +import java.util.Random; +import java.util.Vector; import javax.swing.JPanel; public class DiskExplorer extends JPanel { public DiskExplorer() { - this.setBackground(Color.GREEN); + this.setBackground(randomColor()); } + private Color randomColor() { + Color colors[] = {Color.black, Color.blue, Color.cyan, + Color.gray, Color.darkGray, Color.green, + Color.lightGray, Color.magenta, Color.orange, + Color.pink,Color.red, Color.white, Color.yellow}; + return colors[(int)(Math.random() * colors.length)]; + } /** * serialVersionUID, to keep Eclipse happy */ diff --git a/src/com/webcodepro/applecommander/ui/swing/SwingAppleCommander.java b/src/com/webcodepro/applecommander/ui/swing/SwingAppleCommander.java index 8b9d708..e7dac78 100644 --- a/src/com/webcodepro/applecommander/ui/swing/SwingAppleCommander.java +++ b/src/com/webcodepro/applecommander/ui/swing/SwingAppleCommander.java @@ -177,14 +177,17 @@ public class SwingAppleCommander extends JFrame implements ActionListener { if (rc == 0) { userPreferences.setDiskImageDirectory(jc.getSelectedFile().getParent()); UserPreferences.getInstance().save(); - if (tabPane.getTitleAt(0).equals(textBundle.get("SwtAppleCommander.AppleCommander"))) { - tabPane.remove(0); - } - tabPane.add(jc.getSelectedFile().getName(),new DiskExplorer()); - tabPane.setSelectedIndex(tabPane.getTabCount()-1); + addDiskExplorerTab(jc.getSelectedFile()); } } + protected void addDiskExplorerTab(File file) { + if (tabPane.getTitleAt(0).equals(textBundle.get("SwtAppleCommander.AppleCommander"))) { + tabPane.remove(0); + } + tabPane.add(file.getName(),new DiskExplorer()); + tabPane.setSelectedIndex(tabPane.getTabCount()-1); + } /** * Close a file. */