• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

JDesktop

Hi guys,

I know it is possible to add JInternalFrames to a JDesktop, however is it possible to add panels to a JDesktop? and then work on the panels to give a templat that is alway there?

Kind regards

Pete
0
peterwittering
Asked:
peterwittering
1 Solution
 
CEHJCommented:
You need a specific background - say an image? I'm getting a sense of deja vu here - was it you? ;-)
0
 
peterwitteringAuthor Commented:
was what me?
0
 
peterwitteringAuthor Commented:
what i intend to do is have two panels one with the login controls on left hand side, and one with the application language selection controls on the right about a 25-75% horizontally.  These need to be visible until a correct username and password is provided.  Upon that the two panel will disappear and open the relevant JInternalFrames relevant to the users rights.  Also a image icon covering the JDesktop background.  I know i could add the two panels to a JInternalframe, however would like them to be there all the time so that the user could not minimise or remove it.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
TimYatesCommented:
JDesktop is a Container, so yes it should be possible

Or of course, you should be able to just use a JInternalFrame that is not closable, iconifiable, or maximisable :-)
0
 
TimYatesCommented:
>> however would like them to be there all the time so that the user could not minimise or remove it.

Ahhh...why not use the GlassPane of your application?

0
 
TimYatesCommented:
Kind of like this (this is a poor example, but you should see what I mean...)

--------

import javax.swing.* ;
import java.awt.* ;
import java.awt.event.* ;

public class LoginTest extends JFrame
{
  class MyGlassPane extends JPanel
  {
    JPanel loginPanel = new JPanel( new FlowLayout() ) ;
    JButton login = new JButton( "Login!" ) ;
    JTextArea username = new JTextArea() ;
    public MyGlassPane()
    {
      setOpaque( false ) ;
      setLayout( new GridBagLayout() ) ;
      loginPanel.add( new JLabel( "Username" ) ) ;
      loginPanel.add( username ) ;
      loginPanel.add( login ) ;
      add( loginPanel ) ;
      login.addActionListener( new ActionListener()
      {
        public void actionPerformed( ActionEvent e )
        {
          // pretend we have logged in successfully!
          glass.setVisible( false ) ;
        }
      } ) ;
    }

    public void paintComponent( Graphics g )
    {
      super.paintComponent( g ) ;
      g.setColor( new Color( 0, 0, 0, 64 ) ) ;
      g.fillRect( 0, 0, this.getWidth(), this.getHeight() ) ;
    }
  }

  MyGlassPane glass = new MyGlassPane() ;
  JDesktopPane desktop = new JDesktopPane() ;

  public LoginTest( String title )
  {
    super( title ) ;
    getContentPane().setLayout( new BorderLayout() ) ;
    getContentPane().add( desktop, BorderLayout.CENTER ) ;
    getContentPane().add( new JLabel( "Another component" ), BorderLayout.NORTH ) ;
    getContentPane().add( new JLabel( "West!" ), BorderLayout.WEST ) ;

    setSize( 800, 600 ) ;
    setGlassPane( glass ) ;
    glass.setVisible( true ) ;
  }

  public static void main( String[] args ) throws HeadlessException
  {
    LoginTest loginTest1 = new LoginTest( "LoginTest" ) ;
    loginTest1.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ) ;
    loginTest1.setLocationRelativeTo( null ) ;
    loginTest1.setVisible( true ) ;
  }
}
0
 
NaeemgCommented:
u need to add JSplit panes for this purpose.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now