Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some UI stuff - system look and feel - same size buttons #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target/
xmage_launcher.log
nbactions.xml
nbactions-*.xml
nb-configuration.xml
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<properties>
<finalproject.name>XMageLauncher-${project.version}</finalproject.name>
<version>0.3.8</version>
<version>0.3.9</version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
Expand Down
27 changes: 16 additions & 11 deletions src/main/java/com/xmage/launcher/XMageLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ private XMageLauncher() {
frame.setIconImage(icon.getImage());

Random r = new Random();
int imageNum = 1 + r.nextInt(17);
ImageIcon background = new ImageIcon(new ImageIcon(XMageLauncher.class.getResource("/backgrounds/" + Integer.toString(imageNum) + ".jpg")).getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH));
URL imageURL = null;
while (imageURL == null) {
int imageNum = 1 + r.nextInt(17);
imageURL = XMageLauncher.class.getResource("/backgrounds/" + imageNum + ".jpg");
}
ImageIcon background = new ImageIcon(new ImageIcon(imageURL).getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH));
mainPanel = new JLabel(background) {
@Override
public Dimension getPreferredSize() {
Expand Down Expand Up @@ -248,7 +252,6 @@ public void actionPerformed(ActionEvent e) {
}
});

constraints.fill = GridBagConstraints.HORIZONTAL;
pnlButtons.add(btnLaunchClientServer, constraints);

btnLaunchServer = new JButton(messages.getString("launchServer"));
Expand Down Expand Up @@ -347,6 +350,7 @@ private void createToolbar() {
Border emptyBorder = BorderFactory.createEmptyBorder();

JButton toolbarButton = new JButton("Settings");
toolbarButton.setFocusPainted(false);
toolbarButton.setBorder(emptyBorder);
toolbarButton.addActionListener(new ActionListener() {
@Override
Expand All @@ -359,6 +363,7 @@ public void actionPerformed(ActionEvent e) {
toolBar.addSeparator();

toolbarButton = new JButton("About");
toolbarButton.setFocusPainted(false);
toolbarButton.setBorder(emptyBorder);
toolbarButton.addActionListener(new ActionListener() {
@Override
Expand All @@ -371,6 +376,7 @@ public void actionPerformed(ActionEvent e) {
toolBar.addSeparator();

toolbarButton = new JButton("Forum");
toolbarButton.setFocusPainted(false);
toolbarButton.setBorder(emptyBorder);
toolbarButton.addActionListener(new ActionListener() {
@Override
Expand All @@ -382,6 +388,7 @@ public void actionPerformed(ActionEvent e) {
toolBar.addSeparator();

toolbarButton = new JButton("Website");
toolbarButton.setFocusPainted(false);
toolbarButton.setBorder(emptyBorder);
toolbarButton.addActionListener(new ActionListener() {
@Override
Expand Down Expand Up @@ -476,16 +483,14 @@ private void localize() {

public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex){
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
XMageLauncher gui = new XMageLauncher();
SwingUtilities.invokeLater(gui);
} catch (ClassNotFoundException ex) {
logger.error("Error: ", ex);
} catch (InstantiationException ex) {
logger.error("Error: ", ex);
} catch (IllegalAccessException ex) {
logger.error("Error: ", ex);
} catch (UnsupportedLookAndFeelException ex) {
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
logger.error("Error: ", ex);
}
}
Expand Down