use of com.github.weisj.darklaf.components.alignment.AlignmentStrategy 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;
}
Aggregations