Solved

Can titlebar of JInternalFrame be made disappear

Posted on 2001-09-12
10
452 Views
Last Modified: 2008-01-09
Hi ,
i want the titlebar of JInternalFrame to be disappeared and in that place i want to add a toolbar in that place,
please can anyone help me

thankyou
kiran
0
Comment
Question by:globalkiran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 6476519
Then you will have not a JInternalFrame.
0
 

Expert Comment

by:lawpan
ID: 6476667
use JWindow
at the same way as JInternalframe
JWindow are normally used as splashscreens.
JWindow myWind = new JWindow();
myWind.add(toolbar);

        myWind.setVisible(false); or show()
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6476727
Yep, the problem with JWindow is that it cannot be moved or added to a JDesktopPane.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:lawpan
ID: 6476736
Yes, this was quite obvouis if you remove the titlebar.
Then you have to implement moving / resize code in another manner. JDesktopPane is not used. The user are using XComponent and JToolbar in his/her description.
0
 
LVL 19

Accepted Solution

by:
Jim Cakalic earned 100 total points
ID: 6476981
You can add a JToolBar to a JInternalFrame the same way that you would add it to a JFrame. In both cases, you create a JToolBar and add it to the NORTH area of the frame's content pane.

    JInternalFrame frame = new JInternalFrame();
    JToolBar toolBar = new JToolBar();
    // customize the toolBar
    frame.getContentPane().add(toolBar, BorderLayout.NORTH);

Removing the titlebar from a JInternalFrame is a little trickier. For this you need to get the UI delegate of the frame and set the Component displayed in it's north pane to null. Don't worry, this 'north' pane is different than the 'north' area of the content pane.

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

Here is a complete working example -- albeit not well written. I hacked it together from code in the Java Tutorial. Look at the createFrame method for the bits that specifically address your question.

The sample code was take from these tutorial examples:
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/InternalFrameDemo.java
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/MyInternalFrame.java
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/ToolBarDemo.java
You can get the images here:
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/images/right.gif
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/images/middle.gif
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/images/left.gif

---------- InternalFrameDemo.java ----------
import javax.swing.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import java.awt.event.*;
import java.awt.*;

public class InternalFrameDemo extends JFrame {
    JDesktopPane desktop;

    public InternalFrameDemo() {
        super("InternalFrameDemo");

        //Make the big window be indented 50 pixels from each edge
        //of the screen.
        int inset = 50;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds(inset, inset,
            screenSize.width - inset*2,
            screenSize.height-inset*2);

        //Quit this app when the big window closes.
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        //Set up the GUI.
        desktop = new JDesktopPane(); //a specialized layered pane
        createFrame(); //Create first window
        setContentPane(desktop);
        setJMenuBar(createMenuBar());

        //Make dragging faster:
        desktop.putClientProperty("JDesktopPane.dragMode", "outline");
    }

    protected JMenuBar createMenuBar() {
        JMenuBar menuBar = new JMenuBar();

        JMenu menu = new JMenu("Document");
        menu.setMnemonic(KeyEvent.VK_D);
        JMenuItem menuItem = new JMenuItem("New");
        menuItem.setMnemonic(KeyEvent.VK_N);
        menuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                createFrame();
            }
        });
        menu.add(menuItem);
        menuBar.add(menu);

        return menuBar;
    }

    protected void createFrame() {
        MyInternalFrame frame = new MyInternalFrame();

        // REMOVE THE FRAME'S TITLEBAR
        BasicInternalFrameUI ui = (BasicInternalFrameUI)frame.getUI();
        ui.setNorthPane(null);

        // ADD THE TOOLBAR
        JToolBar tb = new JToolBar();
        addButtons(tb);
        frame.getContentPane().add(tb, BorderLayout.NORTH);

        frame.setVisible(true); //necessary as of kestrel
        desktop.add(frame);
        try {
            frame.setSelected(true);
        } catch (java.beans.PropertyVetoException e) {
        }
    }

   
    protected void addButtons(JToolBar toolBar) {
        JButton button = null;

        //first button
        button = new JButton(new ImageIcon("images/left.gif"));
        button.setToolTipText("This is the left button");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                displayResult("Action for first button");
            }
        });
        toolBar.add(button);

        //second button
        button = new JButton(new ImageIcon("images/middle.gif"));
        button.setToolTipText("This is the middle button");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                displayResult("Action for second button");
            }
        });
        toolBar.add(button);

        //third button
        button = new JButton(new ImageIcon("images/right.gif"));
        button.setToolTipText("This is the right button");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                displayResult("Action for third button");
            }
        });
        toolBar.add(button);
    }

    protected void displayResult(String actionDescription) {
        System.out.println(actionDescription + "\n");
    }


    public static void main(String[] args) {
        InternalFrameDemo frame = new InternalFrameDemo();
        frame.setVisible(true);
    }
}
---------- end ----------

Best regards,
Jim Cakalic
0
 

Author Comment

by:globalkiran
ID: 6478545
Thanks  jim_cakalic,we got your code,
we implemented it successfully.
Thankyou onceagain
Regards
kiran
0
 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 6479843
Glad to be of assistance :-)
0
 
LVL 20

Expert Comment

by:Venabili
ID: 8908874
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points for jim_cakalic

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venabili
EE Cleanup Volunteer
0
 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 8916631
OK. Thanks.
Jim
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I remove an object from a 3 53
pagenation logic how it is working in my code 1 71
jmeter usage 4 38
maven not picking latest jar instead picking old jar from .m2 12 50
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question