use of com.l2fprod.common.swing.PercentLayout in project cytoscape-impl by cytoscape.
the class CyCustomGraphicsPropertyEditor method getCustomEditor.
@Override
public Component getCustomEditor() {
System.out.println(">>>>>>>>>> " + super.getCustomEditor());
if (editor == null) {
editor = new JPanel(new PercentLayout(PercentLayout.HORIZONTAL, 0));
((JPanel) editor).setOpaque(false);
((JPanel) editor).add("*", label = new CyCustomGraphicsCellRenderer());
label.setOpaque(false);
final IconManager iconManager = serviceRegistrar.getService(IconManager.class);
// TODO just use double-click to open editor--remove buttons!!!
((JPanel) editor).add(button = ComponentFactory.Helper.getFactory().createMiniButton());
button.setText(IconManager.ICON_ELLIPSIS_H);
button.setFont(iconManager.getIconFont(13.0f));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
editChart();
}
});
((JPanel) editor).add(button = ComponentFactory.Helper.getFactory().createMiniButton());
button.setText(IconManager.ICON_REMOVE);
button.setFont(iconManager.getIconFont(13.0f));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
CyCustomGraphics<?> old = customGraphics;
label.setValue(null);
customGraphics = null;
firePropertyChange(old, null);
}
});
}
return super.getCustomEditor();
}
use of com.l2fprod.common.swing.PercentLayout in project CodenameOne by codenameone.
the class BasicOutlookBarUI method tabAdded.
protected void tabAdded(final Component newTab) {
TabButton button = (TabButton) tabToButton.get(newTab);
if (button == null) {
button = createTabButton();
// save the button original color,
// later they would be restored if the button colors are not customized on
// the OutlookBar
button.putClientProperty(BUTTON_ORIGINAL_FOREGROUND, button.getForeground());
button.putClientProperty(BUTTON_ORIGINAL_BACKGROUND, button.getBackground());
buttonToTab.put(button, newTab);
tabToButton.put(newTab, button);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final Component current = getVisibleComponent();
Component target = newTab;
// tabPane allows animation
if (((JOutlookBar) tabPane).isAnimated() && current != target && current != null && target != null) {
if (animator != null) {
animator.stop();
}
animator = new PercentLayoutAnimator(tabPane, (PercentLayout) tabPane.getLayout()) {
protected void complete() {
super.complete();
tabPane.setSelectedComponent(newTab);
nextVisibleComponent = null;
// animation
if (current.getParent() == tabPane) {
((PercentLayout) tabPane.getLayout()).setConstraint(current, "100%");
}
}
};
nextVisibleComponent = newTab;
animator.setTargetPercent(current, 1.0f, 0.0f);
animator.setTargetPercent(newTab, 0.0f, 1.0f);
animator.start();
} else {
nextVisibleComponent = null;
tabPane.setSelectedComponent(newTab);
}
}
});
} else {
// the tab is already in the list, remove the button, it will be
// added again later
tabPane.remove(button);
}
// update the button with the tab information
updateTabButtonAt(tabPane.indexOfComponent(newTab));
int index = indexOfComponent(newTab);
tabPane.add(button, index);
// introduced by J2SE 5
if (JVM.current().isOneDotFive()) {
assureRectsCreated(tabPane.getTabCount());
}
}
Aggregations