Solved

Can titlebar of JInternalFrame be made disappear

Posted on 2001-09-12
10
417 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping3 challenge 14 70
Eclipse Neon and jdk 1.8.0 11 138
Systems talking to each other 5 125
what is the main difference between git clone and fetch ann pull and push commands 2 72
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now