use of javax.swing.JComponent in project jdk8u_jdk by JetBrains.
the class Test4682386 method testSwingProperties.
/**
* Should be exectuted with $JAVA_HOME/lib/dt.jar in the classpath
* so that there will be a lot more bound properties.
* <p/>
* This test isn't really appropriate for automated testing.
*/
private static void testSwingProperties() {
long start = System.currentTimeMillis();
for (Class type : TYPES) {
try {
Object bean = Beans.instantiate(type.getClassLoader(), type.getName());
JComponent comp = (JComponent) bean;
for (int k = 0; k < NUM_LISTENERS; k++) {
comp.addPropertyChangeListener(new PropertyListener());
}
for (PropertyDescriptor pd : getPropertyDescriptors(type)) {
if (pd.isBound()) {
if (DEBUG) {
System.out.println("Bound property found: " + pd.getName());
}
Method read = pd.getReadMethod();
Method write = pd.getWriteMethod();
try {
write.invoke(bean, getValue(pd.getPropertyType(), read.invoke(bean)));
} catch (Exception ex) {
// do nothing - just move on.
if (DEBUG) {
System.out.println("Reflective method invocation Exception for " + type + " : " + ex.getMessage());
}
}
}
}
} catch (Exception ex) {
// do nothing - just move on.
if (DEBUG) {
System.out.println("Exception for " + type.getName() + " : " + ex.getMessage());
}
}
}
System.out.println("Exec time (ms): " + (System.currentTimeMillis() - start));
}
use of javax.swing.JComponent in project pcgen by PCGen.
the class SplashScreen method initComponents.
private void initComponents() {
JComponent pane = new JPanel(new BorderLayout());
pane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 3));
Component splashLabel = new JLabel(Icons.SplashPcgen_Ennie.getImageIcon());
pane.add(splashLabel, BorderLayout.NORTH);
loadingLabel.setBorder(BorderFactory.createEmptyBorder(10, 7, 10, 10));
pane.add(loadingLabel, BorderLayout.CENTER);
loadProgress.setStringPainted(true);
pane.add(loadProgress, BorderLayout.SOUTH);
Container cont = getContentPane();
cont.setLayout(new GridLayout(1, 1));
cont.add(pane);
pack();
setLocationRelativeTo(null);
}
use of javax.swing.JComponent in project pcgen by PCGen.
the class PCGenFrame method initComponents.
private void initComponents() {
setLayout(new BorderLayout());
JComponent root = getRootPane();
root.setActionMap(actionMap);
root.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, createInputMap(actionMap));
characterTabs.add(new InfoGuidePane(this));
setJMenuBar(new PCGenMenuBar(this));
add(new PCGenToolBar(this), BorderLayout.NORTH);
add(characterTabs, BorderLayout.CENTER);
add(statusBar, BorderLayout.SOUTH);
updateTitle();
setIconImage(Icons.PCGenApp.getImageIcon().getImage());
}
use of javax.swing.JComponent in project pcgen by PCGen.
the class PCGenFrame method showMessageConfirm.
private boolean showMessageConfirm(String title, String message) {
JComponent msgComp = getComponentForMessage(message);
int ret = JOptionPane.showConfirmDialog(this, msgComp, title, JOptionPane.YES_NO_OPTION);
return ret == JOptionPane.YES_OPTION;
}
use of javax.swing.JComponent in project pcgen by PCGen.
the class SummaryPanel method setupDisplay.
/**
* @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject)
*/
@Override
public void setupDisplay(JPanel panel, CDOMObject pc) {
panel.setLayout(new GridBagLayout());
JLabel introLabel = new JLabel("Ready to convert.");
GridBagConstraints gbc = new GridBagConstraints();
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(50, 25, 10, 25);
panel.add(introLabel, gbc);
JLabel instructLabel = new JLabel("Press Next to begin converting using the following settings:");
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(10, 25, 20, 25);
panel.add(instructLabel, gbc);
JLabel[] labels = new JLabel[4];
JComponent[] values = new JComponent[4];
labels[0] = new JLabel("Source Folder:");
labels[1] = new JLabel("Destination Folder:");
labels[2] = new JLabel("Game mode:");
labels[3] = new JLabel("Sources:");
values[0] = new JLabel(pc.get(ObjectKey.DIRECTORY).getAbsolutePath());
values[1] = new JLabel(pc.get(ObjectKey.WRITE_DIRECTORY).getAbsolutePath());
values[2] = new JLabel(pc.get(ObjectKey.GAME_MODE).getDisplayName());
List<Campaign> campaigns = pc.getSafeListFor(ListKey.CAMPAIGN);
StringBuilder campDisplay = new StringBuilder();
for (int i = 0; i < campaigns.size(); i++) {
campDisplay.append(campaigns.get(i).getDisplayName());
campDisplay.append("\n");
}
JTextArea campText = new JTextArea(campDisplay.toString());
campText.setEditable(false);
JScrollPane scrollPane = new JScrollPane(campText);
values[3] = scrollPane;
// Place the labels on the page and lay them out
Font plainFont = FontManipulation.plain(panel.getFont());
for (int i = 0; i < labels.length; i++) {
Utility.buildRelativeConstraints(gbc, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(10, 25, 10, 10);
panel.add(labels[i], gbc);
if (i < labels.length - 1) {
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
} else {
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
}
gbc.insets = new Insets(10, 10, 10, 25);
panel.add(values[i], gbc);
values[i].setFont(plainFont);
}
}
Aggregations