Fix NPE in Reseeder.

Tried to make style more portable across defaultLookAndFeels.
This commit is contained in:
dev
2011-08-02 13:47:09 +00:00
parent 3ff64337d2
commit d525a8b593
3 changed files with 34 additions and 13 deletions

View File

@ -5,18 +5,19 @@ import java.awt.Font;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.plaf.FontUIResource; import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.InsetsUIResource;
public class GUIHelper { public class GUIHelper {
private final static Color VERY_LIGHT = new Color(230,230,230); public final static Color VERY_LIGHT = new Color(230,230,230);
private final static Color LIGHT = new Color(215,215,215); public final static Color LIGHT = new Color(215,215,215);
private final static Color MEDIUM = new Color (175,175,175); public final static Color MEDIUM = new Color (175,175,175);
private final static Color DARK = new Color(145,145,145); public final static Color DARK = new Color(145,145,145);
public final static FontUIResource DEFAULT_FONT = new FontUIResource(Font.SANS_SERIF,Font.PLAIN,12); public final static FontUIResource DEFAULT_FONT = new FontUIResource(Font.SANS_SERIF,Font.PLAIN,12);
public static void setDefaultStyle(){ public static void setDefaultStyle(){
//Selected tab //Selected tab
UIManager.put("TabbedPane.focus", VERY_LIGHT); UIManager.put("TabbedPane.focus", VERY_LIGHT);
UIManager.put("TabbedPane.selected", VERY_LIGHT); UIManager.put("TabbedPane.selected", LIGHT);
UIManager.put("TabbedPane.selectHighlight", Color.BLACK); UIManager.put("TabbedPane.selectHighlight", Color.BLACK);
//General shadow around each tab //General shadow around each tab
UIManager.put("TabbedPane.light", Color.WHITE); UIManager.put("TabbedPane.light", Color.WHITE);
@ -26,6 +27,7 @@ public class GUIHelper {
UIManager.put("Button.background", Color.WHITE); UIManager.put("Button.background", Color.WHITE);
setDefaultFonts(); setDefaultFonts();
setTabLooks();
} }
private static void setDefaultFonts(){ private static void setDefaultFonts(){
@ -61,4 +63,13 @@ public class GUIHelper {
UIManager.put("ToolTip.font", DEFAULT_FONT); UIManager.put("ToolTip.font", DEFAULT_FONT);
UIManager.put("Tree.font", DEFAULT_FONT); UIManager.put("Tree.font", DEFAULT_FONT);
} }
public static void setTabLooks(){
UIManager.put("TabbedPane.font",new FontUIResource(Font.SANS_SERIF,Font.PLAIN,13));
UIManager.put("TabbedPane.contentBorderInsets", new InsetsUIResource(2, 2, 3, 3));
UIManager.put("TabbedPane.tabAreaInsets", new InsetsUIResource(3,2,0,2));
UIManager.put("TabbedPane.tabInsets", new InsetsUIResource(6,4,2,4));
UIManager.put("TabbedPane.textIconGap", 4);
//UIManager.put(key, value)
}
} }

View File

@ -1,14 +1,17 @@
package net.i2p.itoopie.gui; package net.i2p.itoopie.gui;
import java.awt.Dimension;
import java.awt.EventQueue; import java.awt.EventQueue;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JRootPane;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
@ -18,6 +21,7 @@ import net.i2p.itoopie.gui.component.util.TabChangeListener;
import net.i2p.itoopie.i18n.Transl; import net.i2p.itoopie.i18n.Transl;
import net.i2p.itoopie.util.IconLoader; import net.i2p.itoopie.util.IconLoader;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
@ -31,6 +35,7 @@ public class Main {
private static JTabbedPane tabbedPane; private static JTabbedPane tabbedPane;
public final static int FRAME_WIDTH = 550; public final static int FRAME_WIDTH = 550;
public final static int FRAME_HEIGHT = 400; public final static int FRAME_HEIGHT = 400;
public final static int TABBED_PANE_HEIGHT = FRAME_HEIGHT -58;
/** /**
* Launch the application. * Launch the application.
@ -60,15 +65,20 @@ public class Main {
*/ */
private void initialize() { private void initialize() {
GUIHelper.setDefaultStyle(); GUIHelper.setDefaultStyle();
//GUIHelper.setTabLooks();
frame = new RegisteredFrame("itoopie"); frame = new RegisteredFrame("itoopie");
frame.setBounds(0, 0, FRAME_WIDTH, FRAME_HEIGHT); frame.setBounds(0, 0, FRAME_WIDTH, FRAME_HEIGHT);
frame.setResizable(false); frame.setResizable(false);
JRootPane root = frame.getRootPane();
root.setLayout(null);
//root.setBorder(BorderFactory.createLineBorder(GUIHelper.MEDIUM));
WindowHandler.registerMain(frame); WindowHandler.registerMain(frame);
tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane = new JTabbedPane(JTabbedPane.TOP);
frame.getContentPane().add(tabbedPane, BorderLayout.CENTER); root.add(tabbedPane);
tabbedPane.setBounds(0, 0, FRAME_WIDTH-9, TABBED_PANE_HEIGHT);
TabLogoPanel overviewTab = new OverviewTab("itoopie-opaque12"); TabLogoPanel overviewTab = new OverviewTab("itoopie-opaque12");
tabbedPane.addTab(Transl._("Overview"), null, overviewTab, null); tabbedPane.addTab(Transl._("Overview"), null, overviewTab, null);
@ -85,8 +95,8 @@ public class Main {
JPanel statusPanel = new JPanel(); JPanel statusPanel = new JPanel();
frame.getContentPane().add(statusPanel, BorderLayout.SOUTH); root.add(statusPanel);
statusPanel.setBounds(100, 15, 100, 100); statusPanel.setBounds(5, TABBED_PANE_HEIGHT + 3, FRAME_WIDTH-5, 28);
statusPanel.setLayout(new BorderLayout(0, 0)); statusPanel.setLayout(new BorderLayout(0, 0));
JLabel statusLbl = StatusHandler.getStatusLbl(); JLabel statusLbl = StatusHandler.getStatusLbl();

View File

@ -32,9 +32,9 @@ import net.i2p.itoopie.security.ItoopieHostnameVerifier;
*/ */
public class ReseedMonitor extends TimerTask{ public class ReseedMonitor extends TimerTask{
private static final Long MIN_KNOWN_PEERS = new Long(30); private static final Long MIN_KNOWN_PEERS = new Long(30);
private Log _log; private static final Log _log;
public void ReseedMonitor(){ static {
_log = LogFactory.getLog(ReseedMonitor.class); _log = LogFactory.getLog(ReseedMonitor.class);
} }