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();
}
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();
}
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);
}
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);
}
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;
}
Aggregations