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.plaf.FontUIResource;
import javax.swing.plaf.InsetsUIResource;
public class GUIHelper {
private final static Color VERY_LIGHT = new Color(230,230,230);
private final static Color LIGHT = new Color(215,215,215);
private final static Color MEDIUM = new Color (175,175,175);
private final static Color DARK = new Color(145,145,145);
public final static Color VERY_LIGHT = new Color(230,230,230);
public final static Color LIGHT = new Color(215,215,215);
public final static Color MEDIUM = new Color (175,175,175);
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 static void setDefaultStyle(){
//Selected tab
UIManager.put("TabbedPane.focus", VERY_LIGHT);
UIManager.put("TabbedPane.selected", VERY_LIGHT);
UIManager.put("TabbedPane.selected", LIGHT);
UIManager.put("TabbedPane.selectHighlight", Color.BLACK);
//General shadow around each tab
UIManager.put("TabbedPane.light", Color.WHITE);
@ -26,6 +27,7 @@ public class GUIHelper {
UIManager.put("Button.background", Color.WHITE);
setDefaultFonts();
setTabLooks();
}
private static void setDefaultFonts(){
@ -61,4 +63,13 @@ public class GUIHelper {
UIManager.put("ToolTip.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;
import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import java.awt.BorderLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JRootPane;
import javax.swing.SwingConstants;
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.util.IconLoader;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@ -31,6 +35,7 @@ public class Main {
private static JTabbedPane tabbedPane;
public final static int FRAME_WIDTH = 550;
public final static int FRAME_HEIGHT = 400;
public final static int TABBED_PANE_HEIGHT = FRAME_HEIGHT -58;
/**
* Launch the application.
@ -60,16 +65,21 @@ public class Main {
*/
private void initialize() {
GUIHelper.setDefaultStyle();
//GUIHelper.setTabLooks();
frame = new RegisteredFrame("itoopie");
frame.setBounds(0, 0, FRAME_WIDTH, FRAME_HEIGHT);
frame.setResizable(false);
JRootPane root = frame.getRootPane();
root.setLayout(null);
//root.setBorder(BorderFactory.createLineBorder(GUIHelper.MEDIUM));
WindowHandler.registerMain(frame);
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");
tabbedPane.addTab(Transl._("Overview"), null, overviewTab, null);
tabbedPane.addChangeListener(new TabChangeListener(overviewTab));
@ -85,8 +95,8 @@ public class Main {
JPanel statusPanel = new JPanel();
frame.getContentPane().add(statusPanel, BorderLayout.SOUTH);
statusPanel.setBounds(100, 15, 100, 100);
root.add(statusPanel);
statusPanel.setBounds(5, TABBED_PANE_HEIGHT + 3, FRAME_WIDTH-5, 28);
statusPanel.setLayout(new BorderLayout(0, 0));
JLabel statusLbl = StatusHandler.getStatusLbl();

View File

@ -32,9 +32,9 @@ import net.i2p.itoopie.security.ItoopieHostnameVerifier;
*/
public class ReseedMonitor extends TimerTask{
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);
}