Search in sources :

Example 11 with JComponent

use of javax.swing.JComponent in project openblocks by mikaelhg.

the class WindowExplorer method setDrawersCard.

/**
     * Reassigns the set of canvases that this explorer controls.
     * Though the collection of canvas mnay be empty, it may not be null.
     * @param items
     *
     * @requires items != null &&
     * 			 for each element in item, element!= null
     */
public void setDrawersCard(List<? extends Canvas> items) {
    canvases.clear();
    buttonPane.removeAll();
    int size = items.size();
    if (size % 2 == 1) {
        size++;
    }
    size = buttonHeight * size;
    buttonPane.setPreferredSize(new Dimension(6, size));
    for (int i = 0; i < items.size(); i++) {
        final int index = i;
        Canvas item = items.get(i);
        //final CButton button = new CButton(item.getColor(), item.getColor().brighter().brighter().brighter(),item.getName());
        CButton button = new CBorderlessButton(item.getName());
        JComponent scroll = new CHoverScrollPane(item.getJComponent(), ScrollPolicy.VERTICAL_BAR_AS_NEEDED, ScrollPolicy.HORIZONTAL_BAR_AS_NEEDED, 18, item.getColor(), Color.darkGray);
        canvases.add(scroll);
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                selectCanvas(index);
            }
        });
        buttonPane.add(button);
    }
    if (!canvases.isEmpty()) {
        canvasPane.add(canvases.get(0));
    }
    this.revalidate();
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JComponent(javax.swing.JComponent) Dimension(java.awt.Dimension)

Example 12 with JComponent

use of javax.swing.JComponent in project smile by haifengl.

the class PlotCanvas method remove.

/**
     * Remove a graphical shape from the canvas.
     */
public void remove(Plot p) {
    shapes.remove(p);
    JComponent[] tb = p.getToolBar();
    if (tb != null) {
        for (JComponent comp : tb) {
            toolbar.remove(comp);
        }
    }
    repaint();
}
Also used : JComponent(javax.swing.JComponent)

Example 13 with JComponent

use of javax.swing.JComponent in project smile by haifengl.

the class IsotonicMDSDemo method run.

@Override
public void run() {
    startButton.setEnabled(false);
    datasetBox.setEnabled(false);
    try {
        JComponent plot = learn();
        if (plot != null) {
            if (canvas != null)
                remove(canvas);
            canvas = plot;
            add(plot, BorderLayout.CENTER);
        }
        validate();
    } catch (Exception ex) {
        System.err.println(ex);
    }
    startButton.setEnabled(true);
    datasetBox.setEnabled(true);
}
Also used : JComponent(javax.swing.JComponent)

Example 14 with JComponent

use of javax.swing.JComponent in project smile by haifengl.

the class SammonMappingDemo method run.

@Override
public void run() {
    startButton.setEnabled(false);
    datasetBox.setEnabled(false);
    try {
        JComponent plot = learn();
        if (plot != null) {
            if (canvas != null)
                remove(canvas);
            canvas = plot;
            add(plot, BorderLayout.CENTER);
        }
        validate();
    } catch (Exception ex) {
        System.err.println(ex);
    }
    startButton.setEnabled(true);
    datasetBox.setEnabled(true);
}
Also used : JComponent(javax.swing.JComponent)

Example 15 with JComponent

use of javax.swing.JComponent in project gephi by gephi.

the class WizardIterator method getPanels.

/**
     * Initialize panels representing individual wizard's steps and sets various
     * properties for them influencing wizard appearance.
     */
private WizardDescriptor.Panel[] getPanels() {
    if (panels == null) {
        panels = new WizardDescriptor.Panel[] { new WizardPanel1(), new WizardPanel2() };
        String[] steps = new String[panels.length];
        for (int i = 0; i < panels.length; i++) {
            Component c = panels[i].getComponent();
            // Default step name to component name of panel.
            steps[i] = c.getName();
            if (c instanceof JComponent) {
                // assume Swing components
                JComponent jc = (JComponent) c;
                // Sets step number of a component
                // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
                // Sets steps names for a panel
                jc.putClientProperty("WizardPanel_contentData", steps);
                // Turn on subtitle creation on each step
                jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
                // Show steps on the left side with the image on the background
                jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
                // Turn on numbering of all steps
                jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
            }
        }
        originalPanels = panels;
    }
    return panels;
}
Also used : JComponent(javax.swing.JComponent) WizardDescriptor(org.openide.WizardDescriptor) JComponent(javax.swing.JComponent) Component(java.awt.Component)

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