Search in sources :

Example 1 with BasicInternalFrameUI

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);
}
Also used : BasicInternalFrameUI(javax.swing.plaf.basic.BasicInternalFrameUI)

Example 2 with BasicInternalFrameUI

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;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) BasicInternalFrameUI(javax.swing.plaf.basic.BasicInternalFrameUI) MouseMotionListener(java.awt.event.MouseMotionListener)

Example 3 with BasicInternalFrameUI

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);
}
Also used : BasicInternalFrameUI(javax.swing.plaf.basic.BasicInternalFrameUI) MouseMotionListener(java.awt.event.MouseMotionListener)

Example 4 with BasicInternalFrameUI

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);
// }
// }
}
Also used : InputEvent(java.awt.event.InputEvent) BufferedImage(java.awt.image.BufferedImage) DefaultEditorKit(javax.swing.text.DefaultEditorKit) InternalFrameEvent(javax.swing.event.InternalFrameEvent) KeyEvent(java.awt.event.KeyEvent) ActionEvent(java.awt.event.ActionEvent) InternalFrameAdapter(javax.swing.event.InternalFrameAdapter) BasicInternalFrameUI(javax.swing.plaf.basic.BasicInternalFrameUI) java.awt(java.awt) Stream(java.util.stream.Stream) Optional(java.util.Optional) MouseListener(java.awt.event.MouseListener) javax.swing(javax.swing) BasicInternalFrameUI(javax.swing.plaf.basic.BasicInternalFrameUI)

Aggregations

BasicInternalFrameUI (javax.swing.plaf.basic.BasicInternalFrameUI)4 MouseMotionListener (java.awt.event.MouseMotionListener)2 java.awt (java.awt)1 ActionEvent (java.awt.event.ActionEvent)1 InputEvent (java.awt.event.InputEvent)1 KeyEvent (java.awt.event.KeyEvent)1 MouseListener (java.awt.event.MouseListener)1 BufferedImage (java.awt.image.BufferedImage)1 PropertyVetoException (java.beans.PropertyVetoException)1 Optional (java.util.Optional)1 Stream (java.util.stream.Stream)1 javax.swing (javax.swing)1 InternalFrameAdapter (javax.swing.event.InternalFrameAdapter)1 InternalFrameEvent (javax.swing.event.InternalFrameEvent)1 DefaultEditorKit (javax.swing.text.DefaultEditorKit)1