use of javax.swing.plaf.basic.BasicInternalFrameUI in project java-swing-tips by aterai.
the class MainPanel method addFrame.
private static void addFrame(JDesktopPane desktop, int idx) {
String titleAlignment = idx == 0 ? "CENTER" : "LEADING";
JInternalFrame frame = new JInternalFrame("title: " + titleAlignment, true, true, true, true);
BasicInternalFrameUI ui = (BasicInternalFrameUI) frame.getUI();
JComponent titleBar = ui.getNorthPane();
UIDefaults d = new UIDefaults();
d.put("InternalFrame:InternalFrameTitlePane.titleAlignment", titleAlignment);
titleBar.putClientProperty("Nimbus.Overrides", d);
frame.add(makePanel());
frame.setSize(240, 100);
frame.setLocation(10 + 60 * idx, 10 + 120 * idx);
desktop.add(frame);
EventQueue.invokeLater(() -> frame.setVisible(true));
// desktop.getDesktopManager().activateFrame(frame);
}
use of javax.swing.plaf.basic.BasicInternalFrameUI in project java-swing-tips by aterai.
the class DragWindowListener method makeInternalFrame.
private static JInternalFrame makeInternalFrame() {
JInternalFrame internal = new JInternalFrame("@title@");
BasicInternalFrameUI ui = (BasicInternalFrameUI) internal.getUI();
Component title = ui.getNorthPane();
for (MouseMotionListener l : title.getListeners(MouseMotionListener.class)) {
title.removeMouseMotionListener(l);
}
DragWindowListener dwl = new DragWindowListener();
title.addMouseListener(dwl);
title.addMouseMotionListener(dwl);
KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
focusManager.addPropertyChangeListener(e -> {
String prop = e.getPropertyName();
// System.out.println(prop);
if ("activeWindow".equals(prop)) {
try {
internal.setSelected(Objects.nonNull(e.getNewValue()));
} catch (PropertyVetoException ex) {
throw new IllegalStateException(ex);
}
// System.out.println("---------------------");
}
});
// });
return internal;
}
use of javax.swing.plaf.basic.BasicInternalFrameUI in project java-swing-tips by aterai.
the class LookAndFeelUtil method updateUI.
@Override
public void updateUI() {
super.updateUI();
BasicInternalFrameUI ui = (BasicInternalFrameUI) getUI();
Component titleBar = ui.getNorthPane();
for (MouseMotionListener l : titleBar.getListeners(MouseMotionListener.class)) {
titleBar.removeMouseMotionListener(l);
}
DragWindowListener dwl = new DragWindowListener();
titleBar.addMouseListener(dwl);
titleBar.addMouseMotionListener(dwl);
}
use of javax.swing.plaf.basic.BasicInternalFrameUI in project java-swing-tips by aterai.
the class TextureUtils method removeSystemMenuListener.
public static void removeSystemMenuListener(JInternalFrame modal) {
BasicInternalFrameUI ui = (BasicInternalFrameUI) modal.getUI();
Container titleBar = ui.getNorthPane();
Stream.of(titleBar.getComponents()).filter(c -> c instanceof JLabel || "InternalFrameTitlePane.menuButton".equals(c.getName())).forEach(MainPanel::removeComponentMouseListener);
// for (Component c : titleBar.getComponents()) {
// if (c instanceof JLabel || "InternalFrameTitlePane.menuButton".equals(c.getName())) {
// removeComponentMouseListener(c);
// }
// }
}
Aggregations