mirror of
https://github.com/SKCraft/Launcher.git
synced 2025-03-11 13:20:33 +01:00
Add a background to the fancy launcher.
This commit is contained in:
parent
5270e81ac3
commit
c734ab751b
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* SKCraft Launcher
|
||||
* Copyright (C) 2010-2014 Albert Pham <http://www.sk89q.com> and contributors
|
||||
* Please see LICENSE.txt for license information.
|
||||
*/
|
||||
|
||||
package com.skcraft.launcher;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class FancyBackgroundPanel extends JPanel {
|
||||
|
||||
private Image background;
|
||||
|
||||
public FancyBackgroundPanel() {
|
||||
try {
|
||||
background = ImageIO.read(FancyBackgroundPanel.class.getResourceAsStream("launcher_bg.jpg"));
|
||||
} catch (IOException e) {
|
||||
background = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
if (background != null) {
|
||||
g.drawImage(background, 0, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,8 +7,12 @@
|
||||
package com.skcraft.launcher;
|
||||
|
||||
import com.skcraft.launcher.dialog.LauncherFrame;
|
||||
import com.skcraft.launcher.swing.SwingHelper;
|
||||
import com.skcraft.launcher.swing.WebpagePanel;
|
||||
import lombok.NonNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class FancyLauncherFrame extends LauncherFrame {
|
||||
|
||||
/**
|
||||
@ -19,8 +23,24 @@ public class FancyLauncherFrame extends LauncherFrame {
|
||||
public FancyLauncherFrame(@NonNull Launcher launcher) {
|
||||
super(launcher);
|
||||
|
||||
setSize(900, 650);
|
||||
setSize(800, 500);
|
||||
setLocationRelativeTo(null);
|
||||
|
||||
SwingHelper.removeOpaqueness(getInstancesTable());
|
||||
SwingHelper.removeOpaqueness(getInstanceScroll());
|
||||
getInstanceScroll().setBorder(BorderFactory.createEmptyBorder());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JPanel createContainerPanel() {
|
||||
return new FancyBackgroundPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WebpagePanel createNewsPanel() {
|
||||
WebpagePanel panel = super.createNewsPanel();
|
||||
panel.setBrowserBorder(BorderFactory.createEmptyBorder());
|
||||
return panel;
|
||||
}
|
||||
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
@ -14,6 +14,7 @@ import com.skcraft.launcher.launch.LaunchListener;
|
||||
import com.skcraft.launcher.swing.*;
|
||||
import com.skcraft.launcher.util.SharedLocale;
|
||||
import com.skcraft.launcher.util.SwingExecutor;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.java.Log;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
@ -40,8 +41,10 @@ public class LauncherFrame extends JFrame {
|
||||
|
||||
private final Launcher launcher;
|
||||
|
||||
@Getter
|
||||
private final InstanceTable instancesTable = new InstanceTable();
|
||||
private final InstanceTableModel instancesModel;
|
||||
@Getter
|
||||
private final JScrollPane instanceScroll = new JScrollPane(instancesTable);
|
||||
private WebpagePanel webView;
|
||||
private JSplitPane splitPane;
|
||||
@ -79,9 +82,10 @@ public class LauncherFrame extends JFrame {
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
setLayout(new MigLayout("fill, insets dialog", "[][]push[][]", "[grow][]"));
|
||||
JPanel container = createContainerPanel();
|
||||
container.setLayout(new MigLayout("fill, insets dialog", "[][]push[][]", "[grow][]"));
|
||||
|
||||
webView = WebpagePanel.forURL(launcher.getNewsURL(), false);
|
||||
webView = createNewsPanel();
|
||||
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, instanceScroll, webView);
|
||||
selfUpdateButton.setVisible(launcher.getUpdateManager().getPendingUpdate());
|
||||
|
||||
@ -101,13 +105,15 @@ public class LauncherFrame extends JFrame {
|
||||
splitPane.setDividerLocation(200);
|
||||
splitPane.setDividerSize(4);
|
||||
splitPane.setOpaque(false);
|
||||
add(splitPane, "grow, wrap, span 5, gapbottom unrel");
|
||||
container.add(splitPane, "grow, wrap, span 5, gapbottom unrel");
|
||||
SwingHelper.flattenJSplitPane(splitPane);
|
||||
add(refreshButton);
|
||||
add(updateCheck);
|
||||
add(selfUpdateButton);
|
||||
add(optionsButton);
|
||||
add(launchButton);
|
||||
container.add(refreshButton);
|
||||
container.add(updateCheck);
|
||||
container.add(selfUpdateButton);
|
||||
container.add(optionsButton);
|
||||
container.add(launchButton);
|
||||
|
||||
add(container, BorderLayout.CENTER);
|
||||
|
||||
instancesModel.addTableModelListener(new TableModelListener() {
|
||||
@Override
|
||||
@ -163,6 +169,19 @@ public class LauncherFrame extends JFrame {
|
||||
});
|
||||
}
|
||||
|
||||
protected JPanel createContainerPanel() {
|
||||
return new JPanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the news panel.
|
||||
*
|
||||
* @return the news panel
|
||||
*/
|
||||
protected WebpagePanel createNewsPanel() {
|
||||
return WebpagePanel.forURL(launcher.getNewsURL(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Popup the menu for the instances.
|
||||
*
|
||||
|
@ -10,6 +10,7 @@ import com.skcraft.launcher.LauncherUtils;
|
||||
import lombok.extern.java.Log;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
@ -35,8 +36,10 @@ public final class WebpagePanel extends JPanel {
|
||||
private URL url;
|
||||
private boolean activated;
|
||||
private JEditorPane documentView;
|
||||
private JScrollPane documentScroll;
|
||||
private JProgressBar progressBar;
|
||||
private Thread thread;
|
||||
private Border browserBorder;
|
||||
|
||||
public static WebpagePanel forURL(URL url, boolean lazy) {
|
||||
return new WebpagePanel(url, lazy);
|
||||
@ -80,6 +83,19 @@ public final class WebpagePanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public Border getBrowserBorder() {
|
||||
return browserBorder;
|
||||
}
|
||||
|
||||
public void setBrowserBorder(Border browserBorder) {
|
||||
synchronized (this) {
|
||||
this.browserBorder = browserBorder;
|
||||
if (documentScroll != null) {
|
||||
documentScroll.setBorder(browserBorder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setDocument() {
|
||||
activated = true;
|
||||
|
||||
@ -100,15 +116,24 @@ public final class WebpagePanel extends JPanel {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(documentView);
|
||||
scrollPane.setOpaque(false);
|
||||
panel.add(scrollPane, new Integer(1));
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
|
||||
documentScroll = new JScrollPane(documentView);
|
||||
documentScroll.setOpaque(false);
|
||||
panel.add(documentScroll, new Integer(1));
|
||||
documentScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
synchronized (this) {
|
||||
if (browserBorder != null) {
|
||||
documentScroll.setBorder(browserBorder);
|
||||
}
|
||||
}
|
||||
|
||||
progressBar = new JProgressBar();
|
||||
progressBar.setIndeterminate(true);
|
||||
panel.add(progressBar, new Integer(2));
|
||||
|
||||
SwingHelper.removeOpaqueness(this);
|
||||
SwingHelper.removeOpaqueness(documentView);
|
||||
SwingHelper.removeOpaqueness(documentScroll);
|
||||
|
||||
add(panel, BorderLayout.CENTER);
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 133 KiB |
Loading…
Reference in New Issue
Block a user