Skip to main content
gamedev.net
🔒 Locked

Java panes

Started by tokenblackguy 0 replies 500+ views
Original Post
tokenblackguy
tokenblackguy
I am making a virtual desktop for a program. I want the user to be able to modify the layout of all the windows, so I decided to use a jDesktopPane and numerous jInternalFrame. The problem is, I don't want the title bar up there. In other words, I don't want frames at all, but rather panes. Is there a way to either get rid of the bar at the top of frames? Or would it be better to just use jDesktopPane's Super Class jLayeredPane? -Token
H_o_p_s
H_o_p_s
Well... the first thing that I would try and do is just make a full screen program, and add your own stuff on that....

But if you want a windowless pane, here is some Open Source splash screen...


import java.awt.*;import javax.swing.*;import java.net.URL;import java.io.Serializable;import javax.imageio.ImageIO;//import org.jazilla.javafe.StringResources;//import org.jazilla.javafe.utils.ImageLoader;/** * A simple class to display a splash screen in the center of the users screen. *  * @author Giao Nguyen, Last Modified By: $Author: Jazilla, H_o_p_s$ */public class Splash extends JWindow implements Serializable{    /*     * The inset from the bottom of the window.  This depends very much     * on the image within which the status is to be displayed!     */    private final static int    STATUS_BOTTOM_INSET = 30;    	private JLabel status = new JLabel(" ");    /**     * Default constructor for Splash Window.     *     * Some of the logic is 'hardwired' even though it really depends on the     * image.  If we wanted flexibility then we'd need to create an ImageXXX     * that, given the status region, would return the predominant color or     * average of colors in that region.  A Color map could then be used to     * figure out what text color would provide good contrast.     *      * I didn't do that... and mozilla doesn't do that.  Here's their code:     *	 *    // The splash screen background is black, so use white text	 *      dc.SetBkColor(RGB(0,0,0));	 *      dc.SetTextColor(RGB(255,255,255));	 *	 * Anyway, this is just to explain the motivation between the 'hardwired'	 * values.  The same applies to the STATUS_BOTTOM_INSET defined above.	 */	public Splash() 	{		JLabel image = new JLabel();		try {			URL url = getClass().getClassLoader().getResource("graphics/Splash.png");			Image initial = ImageIO.read(url);			image = new JLabel(new ImageIcon(initial));		} catch (java.io.IOException ioe) {System.out.println("Exception: "+ioe);}		status.setOpaque(false);		status.setBackground( Color.black );		status.setForeground( Color.black );				FontMetrics f = status.getFontMetrics(status.getFont());		        // Add widgets to content pane        Container content_pane = getContentPane();		content_pane.setLayout(null);		content_pane.add(status); 		content_pane.add(image);         Dimension image_size = image.getPreferredSize();        // Splash size is set to image size		setSize( image_size );		        // Layout widgets on content pane 		image.setBounds( 0, 0, image_size.width, image_size.height );        // Status has no size since it has no text.  We can, however,        // fix its y-axis location.	// Change by Al: Status fiex to width of the dialog so that when text changes	// the status bar area doesn't contain any old text left over (contact al@alsutton.com	// for more info)		status.setLocation( 0 , getSize().height - f.getHeight() - STATUS_BOTTOM_INSET );		Dimension statusSize = new Dimension( getSize().width, f.getHeight());		status.setSize( statusSize );		status.setHorizontalAlignment( SwingConstants.CENTER );	    setLocation(findScreenCenter());	}	/**	 * Display some text (like "loading xyz...")	 * at the bottom of the Splash window	 * @param key the key of the message (e.g. "label.loadingPreferences")	 */	public void setStatus(String key) 	{		status.setText(key);	}    private Point findScreenCenter()     {		Dimension screenSize = 	    	Toolkit.getDefaultToolkit().getScreenSize();		Dimension mySize = getSize();		Point fin = new Point(0, 0);		fin.x = (screenSize.width - mySize.width) / 2;		fin.y = (screenSize.height - mySize.height) / 2;		return fin;    }}



Hope this helps...
BRING BACK THE BLACK (or at least something darker)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.