Search in sources :

Example 26 with JComponent

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));
}
Also used : PropertyDescriptor(java.beans.PropertyDescriptor) JComponent(javax.swing.JComponent) Method(java.lang.reflect.Method) IntrospectionException(java.beans.IntrospectionException)

Example 27 with JComponent

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);
}
Also used : JPanel(javax.swing.JPanel) Container(java.awt.Container) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 28 with JComponent

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());
}
Also used : BorderLayout(java.awt.BorderLayout) JComponent(javax.swing.JComponent)

Example 29 with JComponent

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;
}
Also used : JComponent(javax.swing.JComponent)

Example 30 with JComponent

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);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) Font(java.awt.Font) Campaign(pcgen.core.Campaign)

Aggregations

JComponent (javax.swing.JComponent)159 Component (java.awt.Component)30 JButton (javax.swing.JButton)22 JPanel (javax.swing.JPanel)22 BorderLayout (java.awt.BorderLayout)18 Dimension (java.awt.Dimension)17 Insets (java.awt.Insets)15 JLabel (javax.swing.JLabel)15 ActionEvent (java.awt.event.ActionEvent)11 JFrame (javax.swing.JFrame)11 Color (java.awt.Color)10 ActionListener (java.awt.event.ActionListener)10 ArrayList (java.util.ArrayList)10 Point (java.awt.Point)9 Container (java.awt.Container)8 GridBagConstraints (java.awt.GridBagConstraints)8 JTextField (javax.swing.JTextField)8 Graphics (java.awt.Graphics)7 GridBagLayout (java.awt.GridBagLayout)7 File (java.io.File)7