use of javax.swing.border.LineBorder in project intellij-community by JetBrains.
the class CodeFragmentTableCellEditorBase method getTableCellEditorComponent.
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
myCodeFragment = (PsiCodeFragment) value;
myDocument = PsiDocumentManager.getInstance(myProject).getDocument(myCodeFragment);
myEditorTextField = createEditorField(myDocument);
if (myEditorTextField != null) {
for (DocumentListener listener : myListeners) {
myEditorTextField.addDocumentListener(listener);
}
myEditorTextField.setDocument(myDocument);
myEditorTextField.setBorder(new LineBorder(table.getSelectionBackground()));
}
return myEditorTextField;
}
use of javax.swing.border.LineBorder in project intellij-community by JetBrains.
the class JBTabsDemo method main.
public static void main(String[] args) {
System.out.println("JBTabs.main");
IconLoader.activate();
final JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout(0, 0));
final int[] count = new int[1];
final JBTabsImpl tabs = new JBTabsImpl(null, ActionManager.getInstance(), null, Disposer.newDisposable());
tabs.setTestMode(true);
//final JPanel flow = new JPanel(new FlowLayout(FlowLayout.CENTER));
//frame.getContentPane().add(flow);
//flow.add(tabs.getComponent());
frame.getContentPane().add(tabs.getComponent(), BorderLayout.CENTER);
JPanel south = new JPanel(new FlowLayout());
south.setOpaque(true);
south.setBackground(Color.white);
final JComboBox pos = new JComboBox(new Object[] { JBTabsPosition.top, JBTabsPosition.left, JBTabsPosition.right, JBTabsPosition.bottom });
pos.setSelectedIndex(0);
south.add(pos);
pos.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
final JBTabsPosition p = (JBTabsPosition) pos.getSelectedItem();
if (p != null) {
tabs.getPresentation().setTabsPosition(p);
}
}
});
final JCheckBox bb = new JCheckBox("Buffered", true);
bb.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setUseBufferedPaint(bb.isSelected());
}
});
south.add(bb);
final JCheckBox f = new JCheckBox("Focused");
f.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setFocused(f.isSelected());
}
});
south.add(f);
final JCheckBox v = new JCheckBox("Vertical");
v.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setSideComponentVertical(v.isSelected());
}
});
south.add(v);
final JCheckBox row = new JCheckBox("Single row", true);
row.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setSingleRow(row.isSelected());
}
});
south.add(row);
final JCheckBox ghosts = new JCheckBox("Ghosts always visible", false);
ghosts.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setGhostsAlwaysVisible(ghosts.isSelected());
}
});
south.add(ghosts);
final JCheckBox stealth = new JCheckBox("Stealth tab", tabs.isStealthTabMode());
stealth.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setStealthTabMode(stealth.isSelected());
}
});
south.add(stealth);
final JCheckBox hide = new JCheckBox("Hide tabs", tabs.isHideTabs());
hide.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setHideTabs(hide.isSelected());
}
});
south.add(hide);
frame.getContentPane().add(south, BorderLayout.SOUTH);
tabs.addListener(new TabsListener.Adapter() {
public void selectionChanged(final TabInfo oldSelection, final TabInfo newSelection) {
System.out.println("TabsWithActions.selectionChanged old=" + oldSelection + " new=" + newSelection);
}
});
final JTree someTree = new Tree() {
public void addNotify() {
//To change body of overridden methods use File | Settings | File Templates.
super.addNotify();
System.out.println("JBTabs.addNotify");
}
public void removeNotify() {
System.out.println("JBTabs.removeNotify");
//To change body of overridden methods use File | Settings | File Templates.
super.removeNotify();
}
};
//someTree.setBorder(new LineBorder(Color.cyan));
tabs.addTab(new TabInfo(someTree)).setText("Tree1").setActions(new DefaultActionGroup(), null).setIcon(AllIcons.Debugger.Frame);
final JTree component = new Tree();
final TabInfo toAnimate1 = new TabInfo(component);
//toAnimate1.setIcon(IconLoader.getIcon("/debugger/console.png"));
final JCheckBox attract1 = new JCheckBox("Attract 1");
attract1.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if (attract1.isSelected()) {
toAnimate1.fireAlert();
} else {
toAnimate1.stopAlerting();
}
}
});
south.add(attract1);
final JCheckBox hide1 = new JCheckBox("Hide 1", toAnimate1.isHidden());
hide1.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
toAnimate1.setHidden(!toAnimate1.isHidden());
}
});
south.add(hide1);
final JCheckBox block = new JCheckBox("Block", false);
block.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
tabs.setPaintBlocked(!block.isSelected(), true);
}
});
south.add(block);
final JCheckBox fill = new JCheckBox("Tab fill in", true);
fill.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
tabs.getPresentation().setActiveTabFillIn(fill.isSelected() ? Color.white : null);
}
});
south.add(fill);
final JButton refire = new JButton("Re-fire attraction");
refire.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
toAnimate1.fireAlert();
}
});
south.add(refire);
final JEditorPane text = new JEditorPane();
text.setEditorKit(new HTMLEditorKit());
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 50; i++) {
buffer.append("1234567890abcdefghijklmnopqrstv1234567890abcdefghijklmnopqrstv1234567890abcdefghijklmnopqrstv<br>");
}
text.setText(buffer.toString());
final JLabel tb = new JLabel("Side comp");
tb.setBorder(new LineBorder(Color.red));
tabs.addTab(new TabInfo(ScrollPaneFactory.createScrollPane(text)).setSideComponent(tb)).setText("Text text text");
tabs.addTab(toAnimate1).append("Tree2", new SimpleTextAttributes(SimpleTextAttributes.STYLE_WAVED, Color.black, Color.red));
tabs.addTab(new TabInfo(new JTable())).setText("Table 1").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 2").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 3").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 4").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 5").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 6").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 7").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 8").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 9").setActions(new DefaultActionGroup(), null);
//tabs.getComponent().setBorder(new EmptyBorder(5, 5, 5, 5));
tabs.setTabSidePaintBorder(5);
tabs.setPaintBorder(1, 1, 1, 1);
tabs.getPresentation().setActiveTabFillIn(Color.white);
tabs.setGhostsAlwaysVisible(true);
//tabs.setBorder(new LineBorder(Color.blue, 5));
tabs.setBorder(new EmptyBorder(30, 30, 30, 30));
tabs.setUiDecorator(new UiDecorator() {
public UiDecoration getDecoration() {
return new UiDecoration(null, new Insets(0, -1, 0, -1));
}
});
tabs.setStealthTabMode(true);
frame.setBounds(1400, 200, 1000, 800);
frame.show();
}
use of javax.swing.border.LineBorder in project intellij-community by JetBrains.
the class LightweightHint method show.
/**
* Shows the hint in the layered pane. Coordinates <code>x</code> and <code>y</code>
* are in <code>parentComponent</code> coordinate system. Note that the component
* appears on 250 layer.
*/
@Override
public void show(@NotNull final JComponent parentComponent, final int x, final int y, final JComponent focusBackComponent, @NotNull final HintHint hintHint) {
myParentComponent = parentComponent;
myHintHint = hintHint;
myFocusBackComponent = focusBackComponent;
LOG.assertTrue(myParentComponent.isShowing());
myEscListener = new MyEscListener();
myComponent.registerKeyboardAction(myEscListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
myComponent.registerKeyboardAction(myEscListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
final JLayeredPane layeredPane = parentComponent.getRootPane().getLayeredPane();
myComponent.validate();
if (!myForceShowAsPopup && (myForceLightweightPopup || fitsLayeredPane(layeredPane, myComponent, new RelativePoint(parentComponent, new Point(x, y)), hintHint))) {
beforeShow();
final Dimension preferredSize = myComponent.getPreferredSize();
if (hintHint.isAwtTooltip()) {
IdeTooltip tooltip = new IdeTooltip(hintHint.getOriginalComponent(), hintHint.getOriginalPoint(), myComponent, hintHint, myComponent) {
@Override
protected boolean canAutohideOn(TooltipEvent event) {
if (!LightweightHint.this.canAutoHideOn(event)) {
return false;
} else if (event.getInputEvent() instanceof MouseEvent) {
return !(hintHint.isContentActive() && event.isIsEventInsideBalloon());
} else if (event.getAction() != null) {
return false;
} else {
return true;
}
}
@Override
protected void onHidden() {
fireHintHidden();
TooltipController.getInstance().resetCurrent();
}
@Override
public boolean canBeDismissedOnTimeout() {
return false;
}
}.setToCenterIfSmall(hintHint.isMayCenterTooltip()).setPreferredPosition(hintHint.getPreferredPosition()).setHighlighterType(hintHint.isHighlighterType()).setTextForeground(hintHint.getTextForeground()).setTextBackground(hintHint.getTextBackground()).setBorderColor(hintHint.getBorderColor()).setBorderInsets(hintHint.getBorderInsets()).setFont(hintHint.getTextFont()).setCalloutShift(hintHint.getCalloutShift()).setPositionChangeShift(hintHint.getPositionChangeX(), hintHint.getPositionChangeY()).setExplicitClose(hintHint.isExplicitClose()).setRequestFocus(hintHint.isRequestFocus()).setHint(true);
myComponent.validate();
myCurrentIdeTooltip = IdeTooltipManager.getInstance().show(tooltip, hintHint.isShowImmediately(), hintHint.isAnimationEnabled());
} else {
final Point layeredPanePoint = SwingUtilities.convertPoint(parentComponent, x, y, layeredPane);
myComponent.setBounds(layeredPanePoint.x, layeredPanePoint.y, preferredSize.width, preferredSize.height);
layeredPane.add(myComponent, JLayeredPane.POPUP_LAYER);
myComponent.validate();
myComponent.repaint();
}
} else {
myIsRealPopup = true;
Point actualPoint = new Point(x, y);
JComponent actualComponent = new OpaquePanel(new BorderLayout());
actualComponent.add(myComponent, BorderLayout.CENTER);
if (isAwtTooltip()) {
int inset = BalloonImpl.getNormalInset();
actualComponent.setBorder(new LineBorder(hintHint.getTextBackground(), inset));
actualComponent.setBackground(hintHint.getTextBackground());
actualComponent.validate();
}
myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(actualComponent, myFocusRequestor).setRequestFocus(myFocusRequestor != null).setFocusable(myFocusRequestor != null).setResizable(myResizable).setMovable(myTitle != null).setTitle(myTitle).setModalContext(false).setShowShadow(isRealPopup() && !isForceHideShadow()).setCancelKeyEnabled(false).setCancelOnClickOutside(myCancelOnClickOutside).setCancelCallback(() -> {
onPopupCancel();
return true;
}).setCancelOnOtherWindowOpen(myCancelOnOtherWindowOpen).createPopup();
beforeShow();
myPopup.show(new RelativePoint(myParentComponent, new Point(actualPoint.x, actualPoint.y)));
}
}
use of javax.swing.border.LineBorder in project intellij-community by JetBrains.
the class DetailsComponentTest method main.
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
final JPanel content = new JPanel(new BorderLayout());
final DetailsComponent d = new DetailsComponent();
content.add(d.getComponent(), BorderLayout.CENTER);
d.setText("This is a Tree");
final JTree c = new Tree();
c.setBorder(new LineBorder(Color.red));
d.setContent(c);
frame.getContentPane().add(content, BorderLayout.CENTER);
final JCheckBox details = new JCheckBox("Details");
details.setSelected(true);
frame.getContentPane().add(details, BorderLayout.SOUTH);
details.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
d.setDetailsModeEnabled(details.isSelected());
}
});
frame.setBounds(300, 300, 300, 300);
frame.show();
}
use of javax.swing.border.LineBorder in project android by JetBrains.
the class PreviewIconsPanel method initializeIconComponents.
private void initializeIconComponents(@NotNull Collection<Density> densities) {
// Sort the densities, so that we always line up icons from highest to lowest densities.
Ordering<Density> densityOrdering = new Ordering<Density>() {
@Override
public int compare(Density left, Density right) {
// The lower the enum index, the higher the density
return Ints.compare(left.ordinal(), right.ordinal());
}
};
densities = densityOrdering.immutableSortedCopy(densities);
for (Density density : densities) {
JPanel iconPanel = new JPanel(new VerticalFlowLayout(false, false));
iconPanel.setBackground(myTheme.getMainColor());
iconPanel.setOpaque(myTheme != Theme.TRANSPARENT);
JBLabel title = new JBLabel(density.getResourceValue());
title.setForeground(myTheme.getAltColor());
iconPanel.add(title);
ImageComponent iconImage = new ImageComponent(null);
iconImage.setBorder(new LineBorder(myTheme.getAltColor()));
iconImage.setOpaque(false);
iconPanel.add(iconImage);
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.PAGE_START;
myIconsPanel.add(iconPanel, c);
myIconImages.put(density, iconImage);
}
}
Aggregations