¿El método Java funciona en Windows pero no en Macintosh?

I had a real weird method which is used to hide JInternalFrame's title bar. Now the dilemma is below method works on windows platform,

((javax.swing.plaf.basic.BasicInternalFrameUI) aXInternalFrame.getUI()).setNorthPane(null);

But not on Macintosh! Any experts have any idea which can explain internal process which makes this method not usable on Mac.

And is there any method which may work on both platform to hide titlebar of JInternalFrame?

Muchas Gracias

preguntado el 28 de agosto de 11 a las 04:08

2 Respuestas

On Mac OS X, an instance of com.apple.laf.AquaInternalFrameUI defines the appearance of internal frames. You can minimize the disparity by setting the isPalette property and disabling the frame icons on Mac OS X specifically, as shown below.

enter image description here

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.plaf.basic.BasicInternalFrameUI;

/** @see http://stackoverflow.com/questions/7218971 */
public class InternalFrame {

    private static final int DELTA = 40;
    private JDesktopPane desktop = new JDesktopPane();
    private int offset = DELTA;

    public InternalFrame() {
        JFrame f = new JFrame("Add Frame");
        f.setPreferredSize(new Dimension(400, 400));
        JPanel p = new JPanel();
        p.add(new JButton(new AbstractAction("Add") {

            public void actionPerformed(ActionEvent e) {
        f.add(p, BorderLayout.SOUTH);
        f.add(desktop, BorderLayout.CENTER);

    private void createInternalFrame() {
        JInternalFrame internalFrame = new JInternalFrame(
            "Internal Frame");//, true, true, true, true);
        internalFrame.setLocation(offset, offset);
        offset += DELTA;
        if (System.getProperty("os.name").startsWith("Mac OS")) {
            internalFrame.putClientProperty("JInternalFrame.isPalette", true);
        } else {
            ((BasicInternalFrameUI) internalFrame.getUI()).setNorthPane(null);

    // take up some space
    private JTabbedPane createTabbedPane() {
        JTabbedPane jtp = new JTabbedPane();
        createTab(jtp, "One");
        createTab(jtp, "Two");
        return jtp;

    private void createTab(JTabbedPane jtp, String s) {
        jtp.add(s, new JLabel("TabbedPane " + s, JLabel.CENTER));

    public static void main(String args[]) {
        EventQueue.invokeLater(new Runnable() {

            public void run() {
                InternalFrame myInternalFrame = new InternalFrame();

Respondido 28 ago 11, 15:08

This may be a hairy corner of Swing. This functionality wasn't added to swing until java 1.5 as far as i recall.

have you tried the Frame.setUndecorated method?


If that doesn't work you may need to drop down and do some JNI on the underlying native window object. I had to do this for similar functionality on windows with the 1.4 jvm.

Respondido 28 ago 11, 09:08

JInternalFrame is a lightweight component; the appearance is provided by the UI delegate, InternalFrameUI. - basurero

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.