From c7527bb2f8610538200bcdc76a509a2ee8f69969 Mon Sep 17 00:00:00 2001 From: Lenni0451 <20379977+Lenni0451@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:47:41 +0100 Subject: [PATCH] Use commons-swing --- build.gradle | 1 + .../raphimc/viaproxy/ui/impl/AccountsTab.java | 10 +- .../raphimc/viaproxy/ui/impl/AdvancedTab.java | 20 +-- .../raphimc/viaproxy/ui/impl/GeneralTab.java | 26 ++-- .../raphimc/viaproxy/ui/impl/RealmsTab.java | 18 +-- .../viaproxy/ui/impl/UISettingsTab.java | 6 +- .../viaproxy/ui/popups/AddAccountPopup.java | 8 +- .../viaproxy/ui/popups/DownloadPopup.java | 6 +- .../java/net/raphimc/viaproxy/util/GBC.java | 121 ------------------ .../viaproxy/util/PaddedVerticalLayout.java | 84 ------------ 10 files changed, 48 insertions(+), 252 deletions(-) delete mode 100644 src/main/java/net/raphimc/viaproxy/util/GBC.java delete mode 100644 src/main/java/net/raphimc/viaproxy/util/PaddedVerticalLayout.java diff --git a/build.gradle b/build.gradle index a242a4e..77ca87e 100644 --- a/build.gradle +++ b/build.gradle @@ -87,6 +87,7 @@ dependencies { include("net.lenni0451:MCPing:1.4.0") { exclude group: "com.google.code.gson", module: "gson" } + include "net.lenni0451.commons:swing:1.4.0" include("net.raphimc.netminecraft:all:2.4.0-SNAPSHOT") { exclude group: "com.google.code.gson", module: "gson" } diff --git a/src/main/java/net/raphimc/viaproxy/ui/impl/AccountsTab.java b/src/main/java/net/raphimc/viaproxy/ui/impl/AccountsTab.java index 5ff91b5..81e201e 100644 --- a/src/main/java/net/raphimc/viaproxy/ui/impl/AccountsTab.java +++ b/src/main/java/net/raphimc/viaproxy/ui/impl/AccountsTab.java @@ -17,6 +17,7 @@ */ package net.raphimc.viaproxy.ui.impl; +import net.lenni0451.commons.swing.GBC; import net.lenni0451.lambdaevents.EventHandler; import net.raphimc.minecraftauth.step.msa.StepMsaDeviceCode; import net.raphimc.minecraftauth.util.MicrosoftConstants; @@ -30,7 +31,6 @@ import net.raphimc.viaproxy.ui.I18n; import net.raphimc.viaproxy.ui.ViaProxyUI; import net.raphimc.viaproxy.ui.events.UIInitEvent; import net.raphimc.viaproxy.ui.popups.AddAccountPopup; -import net.raphimc.viaproxy.util.GBC; import net.raphimc.viaproxy.util.TFunction; import org.apache.http.impl.client.CloseableHttpClient; @@ -67,7 +67,7 @@ public class AccountsTab extends AUITab { int gridy = 0; { JLabel infoLabel = new JLabel("
" + I18n.get("tab.accounts.description.line1") + "
" + I18n.get("tab.accounts.description.line2") + "
"); - GBC.create(body).grid(0, gridy++).weightx(1).insets(BORDER_PADDING, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(infoLabel); + GBC.create(body).grid(0, gridy++).weightx(1).insets(BORDER_PADDING, BORDER_PADDING, 0, BORDER_PADDING).fill(GBC.HORIZONTAL).add(infoLabel); } { JScrollPane scrollPane = new JScrollPane(); @@ -156,7 +156,7 @@ public class AccountsTab extends AUITab { contextMenu.add(moveDown); } this.accountsList.setComponentPopupMenu(contextMenu); - GBC.create(body).grid(0, gridy++).weight(1, 1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.BOTH).add(scrollPane); + GBC.create(body).grid(0, gridy++).weight(1, 1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, BORDER_PADDING).fill(GBC.BOTH).add(scrollPane); } { final JPanel addButtons = new JPanel(); @@ -202,9 +202,9 @@ public class AccountsTab extends AUITab { JPanel border = new JPanel(); border.setLayout(new GridBagLayout()); border.setBorder(BorderFactory.createTitledBorder(I18n.get("tab.accounts.add.title"))); - GBC.create(border).grid(0, 0).weightx(1).insets(2, 4, 4, 4).fill(GridBagConstraints.HORIZONTAL).add(addButtons); + GBC.create(border).grid(0, 0).weightx(1).insets(2, 4, 4, 4).fill(GBC.HORIZONTAL).add(addButtons); - GBC.create(body).grid(0, gridy++).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(border); + GBC.create(body).grid(0, gridy++).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING).fill(GBC.HORIZONTAL).add(border); } contentPane.setLayout(new BorderLayout()); diff --git a/src/main/java/net/raphimc/viaproxy/ui/impl/AdvancedTab.java b/src/main/java/net/raphimc/viaproxy/ui/impl/AdvancedTab.java index 116a26b..f674dd0 100644 --- a/src/main/java/net/raphimc/viaproxy/ui/impl/AdvancedTab.java +++ b/src/main/java/net/raphimc/viaproxy/ui/impl/AdvancedTab.java @@ -20,6 +20,7 @@ package net.raphimc.viaproxy.ui.impl; import com.viaversion.viaversion.util.DumpUtil; import gs.mclo.api.MclogsClient; import gs.mclo.api.response.UploadLogResponse; +import net.lenni0451.commons.swing.GBC; import net.lenni0451.lambdaevents.EventHandler; import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.saves.impl.UISave; @@ -28,7 +29,6 @@ import net.raphimc.viaproxy.ui.I18n; import net.raphimc.viaproxy.ui.ViaProxyUI; import net.raphimc.viaproxy.ui.events.UICloseEvent; import net.raphimc.viaproxy.ui.events.UIInitEvent; -import net.raphimc.viaproxy.util.GBC; import net.raphimc.viaproxy.util.logging.Logger; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender; @@ -73,48 +73,48 @@ public class AdvancedTab extends AUITab { { JLabel bindPortLabel = new JLabel(I18n.get("tab.advanced.bind_port.label")); bindPortLabel.setToolTipText(I18n.get("tab.advanced.bind_port.tooltip")); - GBC.create(body).grid(0, gridy++).insets(BORDER_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(bindPortLabel); + GBC.create(body).grid(0, gridy++).insets(BORDER_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(bindPortLabel); this.bindPort = new JSpinner(new SpinnerNumberModel(25568, 1, 65535, 1)); this.bindPort.setToolTipText(I18n.get("tab.advanced.bind_port.tooltip")); ViaProxy.getSaveManager().uiSave.loadSpinner("bind_port", this.bindPort); - GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.bindPort); + GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GBC.HORIZONTAL).add(this.bindPort); } { JLabel proxyLabel = new JLabel(I18n.get("tab.advanced.proxy_url.label")); proxyLabel.setToolTipText(I18n.get("tab.advanced.proxy_url.tooltip")); - GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(proxyLabel); + GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(proxyLabel); this.proxy = new JTextField(); this.proxy.setToolTipText(I18n.get("tab.advanced.proxy_url.tooltip")); ViaProxy.getSaveManager().uiSave.loadTextField("proxy", this.proxy); - GBC.create(body).grid(0, gridy++).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.proxy); + GBC.create(body).grid(0, gridy++).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GBC.HORIZONTAL).add(this.proxy); } { this.proxyOnlineMode = new JCheckBox(I18n.get("tab.advanced.proxy_online_mode.label")); this.proxyOnlineMode.setToolTipText(I18n.get("tab.advanced.proxy_online_mode.tooltip")); ViaProxy.getSaveManager().uiSave.loadCheckBox("proxy_online_mode", this.proxyOnlineMode); - GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.proxyOnlineMode); + GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(this.proxyOnlineMode); } { this.legacySkinLoading = new JCheckBox(I18n.get("tab.advanced.legacy_skin_loading.label")); this.legacySkinLoading.setToolTipText(I18n.get("tab.advanced.legacy_skin_loading.tooltip")); ViaProxy.getSaveManager().uiSave.loadCheckBox("legacy_skin_loading", this.legacySkinLoading); - GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.legacySkinLoading); + GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(this.legacySkinLoading); } { this.chatSigning = new JCheckBox(I18n.get("tab.advanced.chat_signing.label")); this.chatSigning.setToolTipText(I18n.get("tab.advanced.chat_signing.tooltip")); this.chatSigning.setSelected(true); ViaProxy.getSaveManager().uiSave.loadCheckBox("chat_signing", this.chatSigning); - GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.chatSigning); + GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(this.chatSigning); } { this.ignorePacketTranslationErrors = new JCheckBox(I18n.get("tab.advanced.ignore_packet_translation_errors.label")); this.ignorePacketTranslationErrors.setToolTipText(I18n.get("tab.advanced.ignore_packet_translation_errors.tooltip")); this.ignorePacketTranslationErrors.setSelected(false); ViaProxy.getSaveManager().uiSave.loadCheckBox("ignore_packet_translation_errors", this.ignorePacketTranslationErrors); - GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.ignorePacketTranslationErrors); + GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(this.ignorePacketTranslationErrors); } parent.add(body, BorderLayout.NORTH); @@ -178,7 +178,7 @@ public class AdvancedTab extends AUITab { JPanel padding = new JPanel(); padding.setLayout(new GridBagLayout()); - GBC.create(padding).grid(0, 0).weightx(1).insets(0, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(footer); + GBC.create(padding).grid(0, 0).weightx(1).insets(0, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING).fill(GBC.HORIZONTAL).add(footer); container.add(padding, BorderLayout.SOUTH); } diff --git a/src/main/java/net/raphimc/viaproxy/ui/impl/GeneralTab.java b/src/main/java/net/raphimc/viaproxy/ui/impl/GeneralTab.java index ed77c58..235bad5 100644 --- a/src/main/java/net/raphimc/viaproxy/ui/impl/GeneralTab.java +++ b/src/main/java/net/raphimc/viaproxy/ui/impl/GeneralTab.java @@ -17,6 +17,7 @@ */ package net.raphimc.viaproxy.ui.impl; +import net.lenni0451.commons.swing.GBC; import net.lenni0451.lambdaevents.EventHandler; import net.raphimc.vialoader.util.VersionEnum; import net.raphimc.viaproxy.ViaProxy; @@ -29,7 +30,6 @@ import net.raphimc.viaproxy.ui.ViaProxyUI; import net.raphimc.viaproxy.ui.events.UICloseEvent; import net.raphimc.viaproxy.ui.events.UIInitEvent; import net.raphimc.viaproxy.util.AddressUtil; -import net.raphimc.viaproxy.util.GBC; import net.raphimc.viaproxy.util.logging.Logger; import javax.swing.*; @@ -83,14 +83,14 @@ public class GeneralTab extends AUITab { } }); discord.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - GBC.create(header).grid(0, 0).width(0).insets(BORDER_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(discord); + GBC.create(header).grid(0, 0).width(0).insets(BORDER_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(discord); JLabel title = new JLabel("ViaProxy"); title.setFont(title.getFont().deriveFont(30F)); - GBC.create(header).grid(1, 0).weightx(1).width(0).insets(BORDER_PADDING, 0, 0, 0).anchor(GridBagConstraints.CENTER).add(title); + GBC.create(header).grid(1, 0).weightx(1).width(0).insets(BORDER_PADDING, 0, 0, 0).anchor(GBC.CENTER).add(title); JLabel copyright = new JLabel("© RK_01 & Lenni0451"); - GBC.create(header).grid(2, 0).width(0).insets(BORDER_PADDING, 0, 0, BORDER_PADDING).anchor(GridBagConstraints.NORTHEAST).add(copyright); + GBC.create(header).grid(2, 0).width(0).insets(BORDER_PADDING, 0, 0, BORDER_PADDING).anchor(GBC.NORTHEAST).add(copyright); parent.add(header, BorderLayout.NORTH); } @@ -103,16 +103,16 @@ public class GeneralTab extends AUITab { { JLabel serverAddressLabel = new JLabel(I18n.get("tab.general.server_address.label")); serverAddressLabel.setToolTipText(I18n.get("tab.general.server_address.tooltip")); - GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(serverAddressLabel); + GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(serverAddressLabel); this.serverAddress = new JTextField(); this.serverAddress.setToolTipText(I18n.get("tab.general.server_address.tooltip")); ViaProxy.getSaveManager().uiSave.loadTextField("server_address", this.serverAddress); - GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.serverAddress); + GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GBC.HORIZONTAL).add(this.serverAddress); } { JLabel serverVersionLabel = new JLabel(I18n.get("tab.general.server_version.label")); - GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(serverVersionLabel); + GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(serverVersionLabel); this.serverVersion = new JComboBox<>(VersionEnum.SORTED_VERSIONS.toArray(new VersionEnum[0])); this.serverVersion.setRenderer(new DefaultListCellRenderer() { @@ -135,21 +135,21 @@ public class GeneralTab extends AUITab { } }); ViaProxy.getSaveManager().uiSave.loadComboBoxVersionEnum("server_version", this.serverVersion); - GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.serverVersion); + GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GBC.HORIZONTAL).add(this.serverVersion); } { JLabel minecraftAccountLabel = new JLabel(I18n.get("tab.general.minecraft_account.label")); - GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(minecraftAccountLabel); + GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(minecraftAccountLabel); this.authMethod = new JComboBox<>(new String[]{I18n.get("tab.general.minecraft_account.option_select_account"), I18n.get("tab.general.minecraft_account.option_no_account"), I18n.get("tab.general.minecraft_account.option_openauthmod")}); ViaProxy.getSaveManager().uiSave.loadComboBox("auth_method", this.authMethod); - GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.authMethod); + GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GBC.HORIZONTAL).add(this.authMethod); } { this.betaCraftAuth = new JCheckBox(I18n.get("tab.general.betacraft_auth.label")); this.betaCraftAuth.setToolTipText(I18n.get("tab.general.betacraft_auth.tooltip")); ViaProxy.getSaveManager().uiSave.loadCheckBox("betacraft_auth", this.betaCraftAuth); - GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.betaCraftAuth); + GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GBC.NORTHWEST).add(this.betaCraftAuth); // Simulate user action on serverVersion to update betaCraftAuth final ActionEvent fakeAction = new ActionEvent(this.serverVersion, ActionEvent.ACTION_PERFORMED, ""); for (ActionListener listener : this.serverVersion.getActionListeners()) { @@ -166,7 +166,7 @@ public class GeneralTab extends AUITab { this.stateLabel = new JLabel(""); this.stateLabel.setVisible(false); - GBC.create(footer).grid(0, 0).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).anchor(GridBagConstraints.WEST).fill(GridBagConstraints.HORIZONTAL).add(this.stateLabel); + GBC.create(footer).grid(0, 0).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).anchor(GBC.WEST).fill(GBC.HORIZONTAL).add(this.stateLabel); this.stateButton = new JButton(I18n.get("tab.general.state.loading")); this.stateButton.addActionListener(event -> { @@ -174,7 +174,7 @@ public class GeneralTab extends AUITab { else if (this.stateButton.getText().equalsIgnoreCase(I18n.get("tab.general.state.stop"))) this.stop(); }); this.stateButton.setEnabled(false); - GBC.create(footer).grid(0, 1).weightx(1).insets(0, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING).anchor(GridBagConstraints.WEST).fill(GridBagConstraints.HORIZONTAL).add(this.stateButton); + GBC.create(footer).grid(0, 1).weightx(1).insets(0, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING).anchor(GBC.WEST).fill(GBC.HORIZONTAL).add(this.stateButton); parent.add(footer, BorderLayout.SOUTH); } diff --git a/src/main/java/net/raphimc/viaproxy/ui/impl/RealmsTab.java b/src/main/java/net/raphimc/viaproxy/ui/impl/RealmsTab.java index 28801bc..af5350c 100644 --- a/src/main/java/net/raphimc/viaproxy/ui/impl/RealmsTab.java +++ b/src/main/java/net/raphimc/viaproxy/ui/impl/RealmsTab.java @@ -18,6 +18,8 @@ package net.raphimc.viaproxy.ui.impl; import com.google.common.collect.Iterables; +import net.lenni0451.commons.swing.GBC; +import net.lenni0451.commons.swing.layouts.VerticalLayout; import net.raphimc.minecraftauth.responsehandler.exception.RealmsResponseException; import net.raphimc.minecraftauth.service.realms.AbstractRealmsService; import net.raphimc.minecraftauth.service.realms.BedrockRealmsService; @@ -34,8 +36,6 @@ import net.raphimc.viaproxy.saves.impl.accounts.MicrosoftAccount; import net.raphimc.viaproxy.ui.AUITab; import net.raphimc.viaproxy.ui.I18n; import net.raphimc.viaproxy.ui.ViaProxyUI; -import net.raphimc.viaproxy.util.GBC; -import net.raphimc.viaproxy.util.PaddedVerticalLayout; import net.raphimc.viaproxy.util.logging.Logger; import org.apache.http.impl.client.CloseableHttpClient; @@ -139,7 +139,7 @@ public class RealmsTab extends AUITab { body.remove(statusLabel); this.addHeader(body, realmsService instanceof JavaRealmsService); final JPanel realmsPanel = new JPanel(); - realmsPanel.setLayout(new PaddedVerticalLayout(5, 5)); + realmsPanel.setLayout(new VerticalLayout(5, 5)); if (worlds.isEmpty()) { JLabel label = new JLabel(I18n.get("tab.realms.no_worlds")); label.setHorizontalAlignment(SwingConstants.CENTER); @@ -173,7 +173,7 @@ public class RealmsTab extends AUITab { } private void addHeader(final JPanel parent, final boolean showType) { - GBC.create(parent).grid(0, 0).weightx(1).insets(5, 5, 5, 5).fill(GridBagConstraints.HORIZONTAL).add(new JLabel(I18n.get("tab.realms.account", this.currentAccount.getDisplayString()))); + GBC.create(parent).grid(0, 0).weightx(1).insets(5, 5, 5, 5).fill(GBC.HORIZONTAL).add(new JLabel(I18n.get("tab.realms.account", this.currentAccount.getDisplayString()))); if (showType && LATEST_JAVA_SNAPSHOT != null) { JComboBox" + I18n.get("popup.login_account.instructions.browser") + "
"); - GBC.create(contentPane).grid(0, 0).weightx(1).insets(BORDER_PADDING, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(browserLabel); + GBC.create(contentPane).grid(0, 0).weightx(1).insets(BORDER_PADDING, BORDER_PADDING, 0, BORDER_PADDING).fill(GBC.HORIZONTAL).add(browserLabel); JLabel urlLabel = new JLabel("" + this.deviceCode.getDirectVerificationUri() + ""); urlLabel.addMouseListener(new MouseAdapter() { @@ -79,10 +79,10 @@ public class AddAccountPopup extends JDialog { AddAccountPopup.this.parent.openURL(AddAccountPopup.this.deviceCode.getDirectVerificationUri()); } }); - GBC.create(contentPane).grid(0, 1).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(urlLabel); + GBC.create(contentPane).grid(0, 1).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GBC.HORIZONTAL).add(urlLabel); JLabel closeInfo = new JLabel("" + I18n.get("popup.login_account.instructions.close") + "
"); - GBC.create(contentPane).grid(0, 2).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(closeInfo); + GBC.create(contentPane).grid(0, 2).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING).fill(GBC.HORIZONTAL).add(closeInfo); } this.setContentPane(contentPane); } diff --git a/src/main/java/net/raphimc/viaproxy/ui/popups/DownloadPopup.java b/src/main/java/net/raphimc/viaproxy/ui/popups/DownloadPopup.java index f6e95f9..b0f5e36 100644 --- a/src/main/java/net/raphimc/viaproxy/ui/popups/DownloadPopup.java +++ b/src/main/java/net/raphimc/viaproxy/ui/popups/DownloadPopup.java @@ -17,10 +17,10 @@ */ package net.raphimc.viaproxy.ui.popups; +import net.lenni0451.commons.swing.GBC; import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.ui.I18n; import net.raphimc.viaproxy.ui.ViaProxyUI; -import net.raphimc.viaproxy.util.GBC; import javax.swing.*; import java.awt.*; @@ -81,12 +81,12 @@ public class DownloadPopup extends JDialog { { this.progressBar = new JProgressBar(); this.progressBar.setStringPainted(true); - GBC.create(contentPane).grid(0, 0).weightx(1).insets(BORDER_PADDING, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.progressBar); + GBC.create(contentPane).grid(0, 0).weightx(1).insets(BORDER_PADDING, BORDER_PADDING, 0, BORDER_PADDING).fill(GBC.HORIZONTAL).add(this.progressBar); } { JButton cancelButton = new JButton(I18n.get("generic.cancel")); cancelButton.addActionListener(event -> this.close(false)); - GBC.create(contentPane).grid(0, 1).weightx(1).insets(BORDER_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(cancelButton); + GBC.create(contentPane).grid(0, 1).weightx(1).insets(BORDER_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING).fill(GBC.HORIZONTAL).add(cancelButton); } this.setContentPane(contentPane); this.start(); diff --git a/src/main/java/net/raphimc/viaproxy/util/GBC.java b/src/main/java/net/raphimc/viaproxy/util/GBC.java deleted file mode 100644 index 56c49ea..0000000 --- a/src/main/java/net/raphimc/viaproxy/util/GBC.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy - * Copyright (C) 2021-2024 RK_01/RaphiMC and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see