1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.HeadlessException;
import java.awt.Insets;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.text.ParseException;
import java.lang.reflect.InvocationTargetException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.synth.SynthLookAndFeel;
/**
* Synth L&F : Test 1 - Defining basic styles for label, button and separators.
* @author me :-)
*/
public class MySynthTestRound1 extends JFrame implements ActionListener {
public MySynthTestRound1() throws HeadlessException {
super("Test Synth n°1 (Setting IDEA frame)");
initGui();
}
/**
* Helper method for creating buttons.
* @param buttonText the text to display on the button
* @param iconImage the Icon image to display on the button
* @return a button
*/
private JButton createButton(String buttonText, String iconImage) {
BufferedImage bufferedImage = null;
try {
bufferedImage = ImageIO.read(getClass().getClassLoader().getResource(iconImage));
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
JButton button = new JButton(buttonText);
if (bufferedImage != null) {
button.setIcon(new ImageIcon(bufferedImage));
}
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setHorizontalTextPosition(SwingConstants.CENTER);
button.setPreferredSize(new Dimension(130, 80));
button.setMinimumSize(new Dimension(130, 80));
button.setName("configurableButtonStyled");
return button;
}
/**
*
* @param buttonText
* @return a button
*/
private JButton createSimpleButton(String buttonText) {
JButton button = new JButton(buttonText);
button.setPreferredSize(new Dimension(125, 30));
button.setMinimumSize(new Dimension(125, 30));
button.setName("actionButtonStyled");
return button;
}
/**
* Nothing interesting in this method. Used only to create and layout
* components on the panel.
*/
private void initGui() {
this.setLayout(new GridBagLayout());
this.setSize(new Dimension(620, 540));
JLabel projectSettingsLabel = new JLabel("Project Settings [SynthTestRound1]");
JLabel ideSettingLabel = new JLabel("IDE Settings");
JButton modulesButton = createButton("Modules", "pictures/modules.png");
JButton compilerButton = createButton("Compiler", "pictures/compiler.png");
JButton projectCodeStyleButton = createButton("<html><p align=\"center\">Project<br>code sytles</p></html>", "pictures/codeStyle.png");
JButton versionControlButton = createButton("Version Control", "pictures/versionControl.png");
JButton guiDesignerButton = createButton("GUI Designer", "pictures/uiDesigner.png");
JSeparator projectSettingSeparator = new JSeparator();
JSeparator ideSettingSeparator = new JSeparator();
JButton generalButton = createButton("General", "pictures/general.png");
JButton appearanceButton = createButton("Appearance", "pictures/appearance.png");
JButton editorButton = createButton("Editor", "pictures/editor.png");
JButton codeCompletionButton = createButton("Code Completion", "pictures/codeCompletion.png");
JButton fileTypesButton = createButton("File Types", "pictures/fileTypes.png");
JButton localHistoryButton = createButton("Local History", "pictures/localHistory.png");
JButton liveTemplatesButton = createButton("Live Templates", "pictures/liveTemplates.png");
JButton fileTemplatesButton = createButton("File Templates", "pictures/fileTemplates.png");
JButton classicViewButton = createSimpleButton("Classic View");
JButton closeButton = createSimpleButton("Close");
closeButton.addActionListener(this);
/* lay-out components on the frame.*/
this.add(projectSettingsLabel,
new GridBagConstraints(0, 0, GridBagConstraints.REMAINDER,
1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(25, 20, 0, 0), 0, 0));
this.add(projectSettingSeparator,
new GridBagConstraints(0, 1, GridBagConstraints.REMAINDER,
1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(10, 20, 0, 20), 0, 0));
this.add(modulesButton,
new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(10, 20, 0, 0), 0, 0));
this.add(compilerButton,
new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(10, 0, 0, 0), 0, 0));
this.add(projectCodeStyleButton,
new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(10, 0, 0, 0), 0, 0));
this.add(versionControlButton,
new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(10, 0, 0, 0), 0, 0));
this.add(guiDesignerButton,
new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(10, 0, 0, 20), 0, 0));
this.add(ideSettingLabel,
new GridBagConstraints(0, 3, GridBagConstraints.REMAINDER,
1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(30, 20, 0, 0), 0, 0));
this.add(ideSettingSeparator,
new GridBagConstraints(0, 4, GridBagConstraints.REMAINDER,
1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(10, 20, 0, 20), 0, 0));
this.add(generalButton,
new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(10, 20, 0, 0), 0, 0));
this.add(appearanceButton,
new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(10, 0, 0, 0), 0, 0));
this.add(editorButton,
new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(10, 0, 0, 0), 0, 0));
this.add(codeCompletionButton,
new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(10, 0, 0, 0), 0, 0));
this.add(fileTypesButton,
new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(0, 20, 0, 0), 0, 0));
this.add(localHistoryButton,
new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(0, 0, 0, 0), 0, 0));
this.add(liveTemplatesButton,
new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(0, 0, 0, 0), 0, 0));
this.add(fileTemplatesButton,
new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(0, 0, 0, 0), 0, 0));
this.add(classicViewButton,
new GridBagConstraints(0, 7, 1, 1, 0.0, 1.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE,
new Insets(50, 20, 10, 0), 0, 0));
this.add(closeButton,
new GridBagConstraints(4, 7, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE,
new Insets(50, 0, 10, 20), 0, 0));
}
/**
* Invoked when an action occurs.
*/
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
public static void main(String[] args) {
Runnable runnable = new Runnable() {
public void run() {
SynthLookAndFeel synth = new SynthLookAndFeel();
try {
synth.load(MySynthTestRound1.class.getResource("synthround1.xml"));
UIManager.setLookAndFeel(synth);
} catch (ParseException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
};
try {
EventQueue.invokeAndWait(runnable);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (InvocationTargetException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
runnable = new Runnable() {
public void run() {
MySynthTestRound1 synthTest1 = new MySynthTestRound1();
synthTest1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
synthTest1.pack();
synthTest1.setLocationRelativeTo(null);
synthTest1.setVisible(true);
}
};
EventQueue.invokeLater(runnable);
}
} |
Partager