Added gradient to all panel to improve looks somewhat.
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
package net.i2p.itoopie.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
|
@ -209,6 +209,7 @@ public class ConfigurationTab extends TabLogoPanel {
|
||||
lblUPNP.setText(Transl._("UPNP:"));
|
||||
|
||||
chkbxUPNP = new JCheckBox(Transl._("Enable UPNP"));
|
||||
chkbxUPNP.setOpaque(false);
|
||||
networkPanel.add(chkbxUPNP);
|
||||
chkbxUPNP.setBounds(127, 85, 120, 15);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import javax.swing.plaf.InsetsUIResource;
|
||||
public class GUIHelper {
|
||||
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_LIGHT = new Color(195,195,195);
|
||||
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);
|
||||
|
@ -70,6 +70,7 @@ public class Main {
|
||||
frame = new RegisteredFrame("itoopie");
|
||||
frame.setBounds(0, 0, FRAME_WIDTH, FRAME_HEIGHT);
|
||||
frame.setResizable(false);
|
||||
frame.setBackground(GUIHelper.VERY_LIGHT);
|
||||
JRootPane root = frame.getRootPane();
|
||||
root.setLayout(null);
|
||||
//root.setBorder(BorderFactory.createLineBorder(GUIHelper.MEDIUM));
|
||||
@ -98,6 +99,7 @@ public class Main {
|
||||
root.add(statusPanel);
|
||||
statusPanel.setBounds(5, TABBED_PANE_HEIGHT + 3, FRAME_WIDTH-5, 28);
|
||||
statusPanel.setLayout(new BorderLayout(0, 0));
|
||||
statusPanel.setBackground(GUIHelper.VERY_LIGHT);
|
||||
|
||||
JLabel statusLbl = StatusHandler.getStatusLbl();
|
||||
statusLbl.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
@ -108,6 +110,7 @@ public class Main {
|
||||
flowLayout.setHgap(10);
|
||||
flowLayout.setVgap(0);
|
||||
statusPanel.add(buttonWrapper, BorderLayout.EAST);
|
||||
buttonWrapper.setBackground(GUIHelper.VERY_LIGHT);
|
||||
|
||||
JButton settingsBtn = new JButton(Transl._("Settings"));
|
||||
buttonWrapper.add(settingsBtn);
|
||||
|
@ -30,6 +30,7 @@ import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
|
||||
|
||||
import net.i2p.itoopie.configuration.ConfigurationManager;
|
||||
import net.i2p.itoopie.gui.StatusHandler.DEFAULT_STATUS;
|
||||
import net.i2p.itoopie.gui.component.GradientPanel;
|
||||
import net.i2p.itoopie.gui.component.RegisteredFrame;
|
||||
import net.i2p.itoopie.i18n.Transl;
|
||||
import net.i2p.itoopie.i2pcontrol.InvalidParametersException;
|
||||
@ -135,31 +136,35 @@ public class SettingsFrame extends RegisteredFrame{
|
||||
setBounds(0, 0, 450, 310);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setResizable(false);
|
||||
getContentPane().setLayout(null);
|
||||
|
||||
//getContentPane().setLayout(null);
|
||||
GradientPanel gPanel = new GradientPanel(null);
|
||||
getContentPane().add(gPanel);
|
||||
|
||||
JPanel connectPanel = new JPanel();
|
||||
connectPanel.setOpaque(false);
|
||||
connectPanel.setLayout(null);
|
||||
connectPanel.setBounds(0, 0, 426, 99);
|
||||
getContentPane().add(connectPanel);
|
||||
gPanel.add(connectPanel);
|
||||
setupConnectPanel(connectPanel);
|
||||
|
||||
|
||||
JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
|
||||
separator.setBounds((96)/2, 108, (getWidth()-96), 2);
|
||||
getContentPane().add(separator);
|
||||
gPanel.add(separator);
|
||||
|
||||
JPanel newChangePanel = new JPanel();
|
||||
newChangePanel.setLayout(null);
|
||||
newChangePanel.setOpaque(false);
|
||||
newChangePanel.setBounds(0, 110, 426, 135);
|
||||
getContentPane().add(newChangePanel);
|
||||
gPanel.add(newChangePanel);
|
||||
setupChangePanel(newChangePanel);
|
||||
|
||||
|
||||
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
buttonPanel.setBounds(0, getHeight()-60, getWidth()-10, 35);
|
||||
getContentPane().add(buttonPanel);
|
||||
buttonPanel.setOpaque(false);
|
||||
gPanel.add(buttonPanel);
|
||||
|
||||
|
||||
JButton btnDone = new JButton(Transl._(" Apply "));
|
||||
|
130
src/net/i2p/itoopie/gui/component/GradientPanel.java
Normal file
130
src/net/i2p/itoopie/gui/component/GradientPanel.java
Normal file
@ -0,0 +1,130 @@
|
||||
package net.i2p.itoopie.gui.component;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.i2p.itoopie.gui.GUIHelper;
|
||||
|
||||
public class GradientPanel extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = -8423076211079261636L;
|
||||
|
||||
public final static int HORIZONTAL = 0;
|
||||
public final static int VERTICAL = 1;
|
||||
public final static int DIAGONAL_LEFT = 2;
|
||||
public final static int DIAGONAL_RIGHT = 3;
|
||||
|
||||
private Color startColor = Color.WHITE;
|
||||
private Color endColor = GUIHelper.MEDIUM_LIGHT;
|
||||
private int direndColortion;
|
||||
private boolean cyclic;
|
||||
private int maxLength;
|
||||
|
||||
public GradientPanel() {
|
||||
super();
|
||||
direndColortion = VERTICAL;
|
||||
cyclic = false;
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public GradientPanel(Color startColor, Color endColor) {
|
||||
super();
|
||||
this.startColor = startColor;
|
||||
this.endColor = endColor;
|
||||
direndColortion = VERTICAL;
|
||||
cyclic = false;
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public GradientPanel(LayoutManager layout) {
|
||||
super(layout);
|
||||
direndColortion = VERTICAL;
|
||||
cyclic = false;
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public GradientPanel(LayoutManager layout, Color startColor, Color endColor) {
|
||||
super(layout);
|
||||
this.startColor = startColor;
|
||||
this.endColor = endColor;
|
||||
direndColortion = VERTICAL;
|
||||
cyclic = false;
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public Color getEndColor() {
|
||||
return endColor;
|
||||
}
|
||||
|
||||
public void setEndColor(Color endColor) {
|
||||
this.endColor = endColor;
|
||||
}
|
||||
|
||||
public Color getStartColor() {
|
||||
return startColor;
|
||||
}
|
||||
|
||||
public void setStartColor(Color startColor) {
|
||||
this.startColor = startColor;
|
||||
}
|
||||
|
||||
public int getDirection() {
|
||||
return direndColortion;
|
||||
}
|
||||
|
||||
public void setDirection(int direndColortion) {
|
||||
this.direndColortion = direndColortion;
|
||||
}
|
||||
|
||||
public boolean istartColoryclic() {
|
||||
return cyclic;
|
||||
}
|
||||
|
||||
public void setCyclic(boolean cyclic) {
|
||||
this.cyclic = cyclic;
|
||||
}
|
||||
|
||||
public void setMaxLength(int maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
if (isOpaque()) {
|
||||
super.paintComponent(g);
|
||||
return;
|
||||
}
|
||||
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
|
||||
GradientPaint paint = null;
|
||||
|
||||
switch (direndColortion) {
|
||||
case HORIZONTAL:
|
||||
paint = new GradientPaint(0, height / 2, startColor, width, height / 2, endColor, cyclic);
|
||||
break;
|
||||
case VERTICAL:
|
||||
paint = new GradientPaint(width / 2, 0, startColor, width / 2, maxLength > 0 ? maxLength : height, endColor, cyclic);
|
||||
break;
|
||||
case DIAGONAL_LEFT:
|
||||
paint = new GradientPaint(0, 0, startColor, width, height, endColor, cyclic);
|
||||
break;
|
||||
case DIAGONAL_RIGHT:
|
||||
paint = new GradientPaint(width, 0, startColor, 0, height, endColor, cyclic);
|
||||
break;
|
||||
}
|
||||
|
||||
if (paint == null) {
|
||||
throw new RuntimeException(
|
||||
"Invalid direndColortion spendColorified in GradientPanel");
|
||||
}
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
Paint oldPaint = g2d.getPaint();
|
||||
g2d.setPaint(paint);
|
||||
g2d.fillRect(0, 0, width, height);
|
||||
g2d.setPaint(oldPaint);
|
||||
|
||||
super.paintComponent(g);
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import javax.swing.SwingUtilities;
|
||||
|
||||
import net.i2p.itoopie.util.IconLoader;
|
||||
|
||||
public class LogoPanel extends JPanel {
|
||||
public class LogoPanel extends GradientPanel {
|
||||
private final static int IMAGE_SIZE = 128;
|
||||
private Image bg;
|
||||
|
||||
@ -31,6 +31,7 @@ public class LogoPanel extends JPanel {
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
g.drawImage(bg, Math.abs(this.getWidth() - IMAGE_SIZE),
|
||||
Math.abs(this.getHeight() - IMAGE_SIZE), null);
|
||||
}
|
||||
|
Reference in New Issue
Block a user