use of java.awt.event.ComponentEvent in project android by JetBrains.
the class DataReducerVisualTest method createLayeredSelection.
private JLayeredPane createLayeredSelection(JComponent host) {
JBLayeredPane layeredPane = new JBLayeredPane();
layeredPane.add(host);
layeredPane.add(mySelection);
layeredPane.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
JLayeredPane host = (JLayeredPane) e.getComponent();
if (host != null) {
Dimension dim = host.getSize();
for (Component c : host.getComponents()) {
c.setBounds(0, 0, dim.width, dim.height);
}
}
}
});
return layeredPane;
}
use of java.awt.event.ComponentEvent in project intellij-community by JetBrains.
the class WelcomeBalloonLayoutImpl method addToPopup.
private void addToPopup(@NotNull BalloonImpl balloon, @NotNull BalloonLayoutData layoutData) {
layoutData.doLayout = this::layoutPopup;
layoutData.configuration = layoutData.configuration.replace(JBUI.scale(myPopupBalloon == null ? 7 : 5), JBUI.scale(12));
if (myPopupBalloon == null) {
final JScrollPane pane = NotificationsManagerImpl.createBalloonScrollPane(myBalloonPanel, true);
pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
pane.getVerticalScrollBar().addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
pane.setBorder(IdeBorderFactory.createEmptyBorder(SystemInfo.isMac ? 2 : 1, 0, 1, 1));
}
@Override
public void componentHidden(ComponentEvent e) {
pane.setBorder(IdeBorderFactory.createEmptyBorder());
}
});
myPopupBalloon = new BalloonImpl(pane, BORDER_COLOR, new Insets(0, 0, 0, 0), FILL_COLOR, true, false, false, true, false, true, 0, false, false, null, false, 0, 0, 0, 0, false, null, null, false, false, false, null, false, null, -1);
myPopupBalloon.setAnimationEnabled(false);
myPopupBalloon.setShadowBorderProvider(new NotificationBalloonShadowBorderProvider(FILL_COLOR, BORDER_COLOR));
myPopupBalloon.setHideListener(() -> myPopupBalloon.getComponent().setVisible(false));
myPopupBalloon.setActionProvider(new BalloonImpl.ActionProvider() {
private BalloonImpl.ActionButton myAction;
@NotNull
@Override
public List<BalloonImpl.ActionButton> createActions() {
myAction = myPopupBalloon.new ActionButton(AllIcons.Ide.Notification.Close, null, null, com.intellij.util.Consumer.EMPTY_CONSUMER);
return Collections.singletonList(myAction);
}
@Override
public void layout(@NotNull Rectangle bounds) {
myAction.setBounds(0, 0, 0, 0);
}
});
}
myBalloonPanel.add(balloon.getContent());
balloon.getContent().putClientProperty(TYPE_KEY, layoutData.type);
Disposer.register(balloon, new Disposable() {
@Override
public void dispose() {
myBalloons.remove(balloon);
myBalloonPanel.remove(balloon.getContent());
updatePopup();
}
});
myBalloons.add(balloon);
updatePopup();
}
use of java.awt.event.ComponentEvent in project intellij-community by JetBrains.
the class ProgressStripeIcon method generateIcon.
@NotNull
public static AsyncProcessIcon generateIcon(@NotNull JComponent component) {
List<Icon> result = ContainerUtil.newArrayList();
if (UIUtil.isUnderAquaBasedLookAndFeel() && !UIUtil.isUnderDarcula()) {
for (int i = 0; i < 2 * JBUI.scale(GradientIcon.GRADIENT); i += JBUI.scale(TRANSLATE)) {
result.add(new GradientIcon(component, i));
}
} else {
for (int i = 0; i < JBUI.scale(StripeIcon.WIDTH); i += JBUI.scale(TRANSLATE)) {
result.add(new StripeIcon(component, i));
}
result = ContainerUtil.reverse(result);
}
Icon passive = result.get(0);
AsyncProcessIcon icon = new AsyncProcessIcon("ProgressWithStripes", result.toArray(new Icon[result.size()]), passive) {
@Override
public Dimension getPreferredSize() {
return new Dimension(component.getWidth(), passive.getIconHeight());
}
};
component.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
super.componentResized(e);
icon.revalidate();
}
});
return icon;
}
use of java.awt.event.ComponentEvent in project intellij-community by JetBrains.
the class FacetStructureConfigurable method initTree.
@Override
protected void initTree() {
super.initTree();
if (!myTreeWasInitialized) {
myTreeWasInitialized = true;
final FacetsTreeCellRenderer separatorRenderer = new FacetsTreeCellRenderer();
final TreeCellRenderer oldRenderer = myTree.getCellRenderer();
myTree.setCellRenderer(new TreeCellRenderer() {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value instanceof MyNode && ((MyNode) value).getConfigurable() instanceof FrameworkDetectionConfigurable) {
return separatorRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
}
return oldRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
}
});
myTree.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
revalidateTree();
}
@Override
public void componentMoved(ComponentEvent e) {
revalidateTree();
}
@Override
public void componentShown(ComponentEvent e) {
revalidateTree();
}
});
}
}
use of java.awt.event.ComponentEvent in project pcgen by PCGen.
the class PCGenFrame method initSettings.
private void initSettings() {
final UIPropertyContext frameContext = UIPropertyContext.createContext("PCGenFrame");
Rectangle screenBounds = getGraphicsConfiguration().getBounds();
//this is the default frame dimensions
setSize(1060, 725);
//center the frame
setLocationRelativeTo(null);
if (!screenBounds.contains(getBounds())) {
setSize((5 * screenBounds.width) / 6, (5 * screenBounds.height) / 6);
//center the frame
setLocationRelativeTo(null);
}
Rectangle frameBounds = getBounds();
frameBounds.x = frameContext.initInt("bounds.x", frameBounds.x);
frameBounds.y = frameContext.initInt("bounds.y", frameBounds.x);
frameBounds.width = frameContext.initInt("bounds.width", frameBounds.width);
frameBounds.height = frameContext.initInt("bounds.height", frameBounds.height);
int extendedState = frameContext.initInt("extendedState", NORMAL);
if (extendedState == ICONIFIED) {
extendedState = NORMAL;
frameContext.setInt("extendedState", NORMAL);
}
setExtendedState(extendedState);
if (checkBounds(frameBounds)) {
setBounds(frameBounds);
}
addPropertyChangeListener("extendedState", frameContext);
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
updateBounds();
}
@Override
public void componentMoved(ComponentEvent e) {
updateBounds();
}
private void updateBounds() {
Rectangle bounds = getBounds();
frameContext.setInt("bounds.x", bounds.x);
frameContext.setInt("bounds.y", bounds.y);
frameContext.setInt("bounds.width", bounds.width);
frameContext.setInt("bounds.height", bounds.height);
}
});
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
PCGenUIManager.closePCGen();
}
});
}
Aggregations