use of com.github.weisj.darklaf.util.Alignment in project darklaf by weisJ.
the class DarkPanelPopupUI method updateBorder.
protected void updateBorder(final boolean notifyPeer) {
if (popupComponent.getTabFrame() != null) {
JTabFrame tabFrame = popupComponent.getTabFrame();
boolean[] status = tabFrame.getContentPane().getStatus();
Alignment alignment = popupComponent.getAlignment();
Insets insets = getBorderSize(tabFrame, alignment, status);
applyBorderInsets(insets);
Component component = popupComponent.getComponent();
popupComponent.doLayout();
popupComponent.repaint();
if (component != null && component != popupComponent) {
component.doLayout();
component.repaint();
}
if (header != null) {
Component headerParent = header.getParent();
if (headerParent != null) {
headerParent.doLayout();
headerParent.repaint();
}
}
if (notifyPeer) {
try {
Component peer = tabFrame.getPopupComponentAt(tabFrame.getPeer(popupComponent.getAlignment()));
peer.firePropertyChange(TabFramePopup.KEY_PEER_INSETS, 0, 1);
} catch (final IndexOutOfBoundsException ignored) {
/* may happen during transfer */
}
}
}
}
use of com.github.weisj.darklaf.util.Alignment in project darklaf by weisJ.
the class ToolTipDemo method createComponent.
@Override
public JComponent createComponent() {
JButton button = new JButton("Demo Button", DemoResources.FOLDER_ICON);
DemoPanel panel = new DemoPanel(button);
ToolTipContext context = new ToolTipContext(button).setAlignment(Alignment.CENTER).setCenterAlignment(Alignment.SOUTH);
ToolTipContext.setDefaultContext(context);
button.setToolTipText(StringUtil.toHtml("<p style=\"color:red;\">This is the ToolTip demo text!\n" + "<p style=\"color:blue;\">This is the ToolTip demo text!\n" + "<p style=\"color:green;\">This is the ToolTip demo text!\n"));
button.putClientProperty(DarkToolTipUI.KEY_STYLE, DarkToolTipUI.VARIANT_BALLOON);
button.putClientProperty(DarkToolTipUI.KEY_CONTEXT, context);
JPanel controlPanel = panel.addControls(3);
controlPanel.add(new JCheckBox("Align inside") {
{
setSelected(context.isAlignInside());
addActionListener(e -> context.setAlignInside(isSelected()));
}
});
controlPanel.add(new JCheckBox("Ignore Border") {
{
setSelected(context.isIgnoreBorder());
addActionListener(e -> context.setIgnoreBorder(isSelected()));
}
});
controlPanel.add(new JCheckBox("Use best fit") {
{
setSelected(context.isBestFit());
addActionListener(e -> context.setUseBestFit(isSelected()));
}
});
controlPanel = panel.addControls();
controlPanel.add(new JLabel("Tooltip Style:", JLabel.RIGHT));
controlPanel.add(new JComboBox<ToolTipStyle>(ToolTipStyle.values()) {
{
setSelectedItem(ToolTipStyle.BALLOON);
addItemListener(e -> button.putClientProperty(DarkToolTipUI.KEY_STYLE, e.getItem()));
}
}, "sgx");
controlPanel.add(new JLabel("Alignment:", JLabel.RIGHT));
controlPanel.add(new JComboBox<Alignment>(Alignment.values()) {
{
setSelectedItem(context.getAlignment());
addItemListener(e -> context.setAlignment((Alignment) e.getItem()));
}
}, "sgx");
controlPanel.add(new JLabel("Center Alignment:", JLabel.RIGHT));
controlPanel.add(new JComboBox<Alignment>(Alignment.values()) {
{
setSelectedItem(context.getCenterAlignment());
addItemListener(e -> context.setCenterAlignment((Alignment) e.getItem()));
}
}, "sgx");
controlPanel.add(new JLabel("Alignment Strategy:", JLabel.RIGHT));
controlPanel.add(new JComboBox<AlignmentStrategy>(AlignmentStrategy.values()) {
{
setSelectedItem(context.getAlignmentStrategy());
addItemListener(e -> context.setAlignmentStrategy((AlignmentStrategy) e.getItem()));
}
}, "sgx");
return panel;
}
use of com.github.weisj.darklaf.util.Alignment in project darklaf by weisJ.
the class JTabFrame method notifySelectionChange.
/**
* Notify the tabFrame that a selection has changed.
*
* @param tabComponent the tab at which the selection has changed.
*/
public void notifySelectionChange(final TabFrameTab tabComponent) {
if (tabComponent == null) {
return;
}
Alignment a = tabComponent.getOrientation();
selectedIndices[a.ordinal()] = tabComponent.isSelected() ? tabComponent.getIndex() : -1;
if (tabComponent.isSelected()) {
for (TabFrameTab tc : tabsForAlignment(a)) {
if (tc != null && tc != tabComponent) {
tc.setSelected(false);
}
}
}
}
use of com.github.weisj.darklaf.util.Alignment in project darklaf by weisJ.
the class JTabFrame method setPopupVisibility.
/*
* Set the visibility of the popup.
*/
private void setPopupVisibility(final TabFrameTab tabComponent, final boolean selected) {
Alignment a = tabComponent.getOrientation();
TabFramePopup c = compsForAlignment(a).get(tabComponent.getIndex());
c.setEnabled(selected);
content.setComponentAt(a, c.getComponent());
content.setEnabled(a, selected);
doLayout();
}
use of com.github.weisj.darklaf.util.Alignment in project darklaf by weisJ.
the class JTabFrame method moveTab.
/**
* Move a tab to a new position.
*
* @param tabComp the tab to move.
* @param a the new alignment position.{@link TabFramePosition#getAlignment()}
*/
public void moveTab(final TabFrameTab tabComp, final Alignment a) {
if (a == tabComp.getOrientation()) {
return;
}
boolean oldSelected = tabComp.isSelected();
Alignment oldAlign = tabComp.getOrientation();
int oldIndex = tabComp.getIndex();
closeTab(oldAlign, oldIndex);
TabFramePopup comp = compsForAlignment(oldAlign).get(oldIndex);
removeTab(oldAlign, oldIndex);
addTab(comp, tabComp, a);
if (oldSelected) {
openTab(a, tabComp.getIndex());
}
doLayout();
getTabContainer(a).repaint();
}
Aggregations