Improved code style and formatting
This commit is contained in:
parent
4f777412f3
commit
adb5c417c5
@ -49,22 +49,22 @@ public class ChatWindow extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 6865098428255463649L;
|
||||
|
||||
// user specific objects
|
||||
// User specific objects
|
||||
private Client client;
|
||||
private LocalDB localDB;
|
||||
|
||||
// GUI components
|
||||
private JPanel contentPane = new JPanel();
|
||||
private PrimaryTextArea messageEnterTextArea = new PrimaryTextArea(space);
|
||||
private JList<User> userList = new JList<>();
|
||||
private JPanel contentPane = new JPanel();
|
||||
private PrimaryTextArea messageEnterTextArea = new PrimaryTextArea(space);
|
||||
private JList<User> userList = new JList<>();
|
||||
private Chat currentChat;
|
||||
private JList<Message> messageList = new JList<>();
|
||||
private JScrollPane scrollPane = new JScrollPane();
|
||||
private JTextPane textPane = new JTextPane();
|
||||
// private JCheckBox jCbChangeMode;
|
||||
private PrimaryButton postButton = new PrimaryButton("Post");
|
||||
private PrimaryButton settingsButton = new PrimaryButton("Settings");
|
||||
private JList<Message> messageList = new JList<>();
|
||||
private JScrollPane scrollPane = new JScrollPane();
|
||||
private int verticalScrollBarMaximumValue = scrollPane.getVerticalScrollBar().getMaximum();
|
||||
private boolean chatOpened = false;
|
||||
private JTextPane textPane = new JTextPane();
|
||||
private PrimaryButton postButton = new PrimaryButton("Post");
|
||||
private PrimaryButton settingsButton = new PrimaryButton("Settings");
|
||||
|
||||
private static int space = 4;
|
||||
|
||||
@ -239,7 +239,7 @@ public class ChatWindow extends JFrame {
|
||||
|
||||
/**
|
||||
* Used to immediately reload the ChatWindow when settings were changed.
|
||||
*
|
||||
*
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public void changeChatWindowColors(String key) {
|
||||
@ -260,8 +260,7 @@ public class ChatWindow extends JFrame {
|
||||
// Scroll Bar Styling
|
||||
scrollPane.getVerticalScrollBar().setBackground(theme.getCellColor());
|
||||
scrollPane.getVerticalScrollBar()
|
||||
.setUI(new PrimaryScrollBar(5, theme.getInteractableBackgroundColor(),
|
||||
new Color(theme.getInteractableBackgroundColor().getRGB() - 50),
|
||||
.setUI(new PrimaryScrollBar(5, theme.getInteractableBackgroundColor(), new Color(theme.getInteractableBackgroundColor().getRGB() - 50),
|
||||
new Color(theme.getInteractableBackgroundColor().getRGB() + 170), true));
|
||||
scrollPane.getHorizontalScrollBar().setBackground(theme.getCellColor());
|
||||
scrollPane.getHorizontalScrollBar()
|
||||
@ -270,9 +269,7 @@ public class ChatWindow extends JFrame {
|
||||
|
||||
// Autoscroll
|
||||
scrollPane.getVerticalScrollBar().addAdjustmentListener(e -> {
|
||||
if ((verticalScrollBarMaximumValue - e.getAdjustable().getMaximum()) == 0) {
|
||||
return;
|
||||
}
|
||||
if ((verticalScrollBarMaximumValue - e.getAdjustable().getMaximum()) == 0) { return; }
|
||||
|
||||
if (chatOpened == true) {
|
||||
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
|
||||
@ -280,8 +277,8 @@ public class ChatWindow extends JFrame {
|
||||
chatOpened = false;
|
||||
return;
|
||||
}
|
||||
if (scrollPane.getVerticalScrollBar().getValue()
|
||||
+ scrollPane.getVerticalScrollBar().getVisibleAmount() + 100 >= scrollPane.getVerticalScrollBar().getMaximum()) {
|
||||
if (scrollPane.getVerticalScrollBar().getValue() + scrollPane.getVerticalScrollBar().getVisibleAmount()
|
||||
+ 100 >= scrollPane.getVerticalScrollBar().getMaximum()) {
|
||||
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
|
||||
verticalScrollBarMaximumValue = scrollPane.getVerticalScrollBar().getMaximum();
|
||||
}
|
||||
|
@ -16,23 +16,23 @@ import envoy.client.Settings;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>PrimaryScrollBar.javaEvent.java</strong><br>
|
||||
* File: <strong>PrimaryScrollBar.java</strong><br>
|
||||
* Created: <strong>14.12.2019</strong><br>
|
||||
*
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public class PrimaryScrollBar extends BasicScrollBarUI{
|
||||
|
||||
public class PrimaryScrollBar extends BasicScrollBarUI {
|
||||
|
||||
private final Dimension d = new Dimension();
|
||||
private int arcSize;
|
||||
private Color scrollBarColor;
|
||||
private Color hoverColor;
|
||||
private Color draggingColor;
|
||||
private boolean isVertical;
|
||||
|
||||
private final int arcSize;
|
||||
private final Color scrollBarColor;
|
||||
private final Color hoverColor;
|
||||
private final Color draggingColor;
|
||||
private final boolean isVertical;
|
||||
|
||||
public PrimaryScrollBar(int arcSize, Color scrollBarColor, Color hoverColor, Color draggingColor, boolean isVertical) {
|
||||
this.arcSize = arcSize;
|
||||
this.arcSize = arcSize;
|
||||
this.scrollBarColor = scrollBarColor;
|
||||
this.hoverColor = hoverColor;
|
||||
this.draggingColor = draggingColor;
|
||||
@ -41,62 +41,45 @@ public class PrimaryScrollBar extends BasicScrollBarUI{
|
||||
|
||||
@Override
|
||||
protected JButton createDecreaseButton(int orientation) {
|
||||
return new JButton() {
|
||||
private static final long serialVersionUID = 1032443171070235890L;
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return d;
|
||||
}
|
||||
};
|
||||
JButton button = new JButton();
|
||||
button.setPreferredSize(d);
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected JButton createIncreaseButton (int orientation) {
|
||||
return new JButton() {
|
||||
|
||||
private static final long serialVersionUID = 7575774542623215803L;
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return d;
|
||||
}
|
||||
};
|
||||
protected JButton createIncreaseButton(int orientation) {
|
||||
JButton button = new JButton();
|
||||
button.setPreferredSize(d);
|
||||
return button;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle r) {
|
||||
}
|
||||
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle r) {}
|
||||
|
||||
@Override
|
||||
protected void paintThumb(Graphics g, JComponent c, Rectangle r) {
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
Color color = null;
|
||||
JScrollBar sb = (JScrollBar) c;
|
||||
if (!sb.isEnabled() || (isVertical == true && r.width > r.height) || (isVertical == false && r.width < r.height)) {
|
||||
return;
|
||||
} else if (isDragging) {
|
||||
color = draggingColor;
|
||||
} else if (isThumbRollover()) {
|
||||
color = hoverColor;
|
||||
} else {
|
||||
color = scrollBarColor;
|
||||
}
|
||||
Color color;
|
||||
JScrollBar sb = (JScrollBar) c;
|
||||
|
||||
if (!sb.isEnabled() || (isVertical && r.width > r.height) || (!isVertical && r.width < r.height)) return;
|
||||
|
||||
if (isDragging) color = draggingColor;
|
||||
else if (isThumbRollover()) color = hoverColor;
|
||||
else color = scrollBarColor;
|
||||
|
||||
g2.setPaint(color);
|
||||
if (isVertical) {
|
||||
g2.setPaint(color);
|
||||
g2.fillRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize);
|
||||
g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor());
|
||||
g2.drawRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize);
|
||||
g2.dispose();
|
||||
}
|
||||
if (!isVertical) {
|
||||
g2.setPaint(color);
|
||||
} else {
|
||||
g2.fillRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize);
|
||||
g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor());
|
||||
g2.drawRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize);
|
||||
g2.dispose();
|
||||
}
|
||||
g2.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user