Example usage for javax.swing JInternalFrame setUI

List of usage examples for javax.swing JInternalFrame setUI

Introduction

In this page you can find the example usage for javax.swing JInternalFrame setUI.

Prototype

@BeanProperty(hidden = true, visualUpdate = true, description = "The UI object that implements the Component's LookAndFeel.")
public void setUI(InternalFrameUI ui) 

Source Link

Document

Sets the UI delegate for this JInternalFrame.

Usage

From source file:org.docx4all.ui.main.WordMLEditor.java

public void createInternalFrame(FileObject f) {
    if (f == null) {
        return;/*  w ww  .j  a  va  2  s. co  m*/
    }

    log.info(VFSUtils.getFriendlyName(f.getName().getURI()));

    JInternalFrame iframe = _iframeMap.get(f.getName().getURI());
    if (iframe != null) {
        iframe.setVisible(true);

    } else {
        iframe = new JInternalFrame(f.getName().getBaseName(), true, true, true, true);
        iframe.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        iframe.addInternalFrameListener(_internalFrameListener);
        iframe.addInternalFrameListener(_toolbarStates);
        iframe.addPropertyChangeListener(WindowMenu.getInstance());

        if (iframe.getUI() instanceof BasicInternalFrameUI) {
            BasicInternalFrameUI ui = (BasicInternalFrameUI) iframe.getUI();
            javax.swing.JComponent northPane = ui.getNorthPane();
            if (northPane == null) {
                // Happens on Mac OSX: Google for "osx java getNorthPane"
                // Fix is from it.businesslogic.ireport.gui.JMDIFrame
                javax.swing.plaf.basic.BasicInternalFrameUI aUI = new javax.swing.plaf.basic.BasicInternalFrameUI(
                        iframe);
                iframe.setUI(aUI);

                // Try again
                ui = (BasicInternalFrameUI) iframe.getUI();
                northPane = ((javax.swing.plaf.basic.BasicInternalFrameUI) ui).getNorthPane();
            }
            northPane.addMouseMotionListener(_titleBarMouseListener);
        }

        JEditorPane editorView = createEditorView(f);
        JPanel panel = FxScriptUIHelper.getInstance().createEditorPanel(editorView);

        iframe.getContentPane().add(panel);
        iframe.pack();
        _desktop.add(iframe);

        editorView.requestFocusInWindow();
        editorView.select(0, 0);

        String filePath = f.getName().getURI();
        iframe.putClientProperty(WordMLDocument.FILE_PATH_PROPERTY, filePath);
        _iframeMap.put(filePath, iframe);

        iframe.show();
    }

    try {
        iframe.setSelected(true);
        iframe.setIcon(false);
        iframe.setMaximum(true);
    } catch (PropertyVetoException exc) {
        // do nothing
    }
}