Results 1 to 2 of 2

Thread: Layered Panes

  1. #1
    teckno101 is offline Member
    Join Date
    Sep 2009
    Posts
    9
    Rep Power
    0

    Default Layered Panes

    I would like to add a JDrawPanel on top of all my other JPanels/Container.

    This is what I have so far, I want to add a JDrawPanel on top of all of that, and still have access to the Fields (below would work too).

    Thanks in advance.
    Java Code:
    import javax.swing.*;  //JButton
    
    import java.awt.*;  //Container and Layouts
    import java.awt.event.*; //Listeners
    import java.text.NumberFormat; //CurrencyFormatter
    
    public class CheckOut extends JFrame
    {
    	public static void main (String[] args)
    	{
    		CheckOut window = new CheckOut();
    		window.setVisible(true); //makes the window visible
    		window.setResizable(false);
    	}
    	
    	public CheckOut()
    	{
    		setTitle("Beach Fee - Check Out v1.0"); //sets the title of window to Bank Teller
        	setSize(400,250); //Sets the size of the window
        	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Makes it so the "X" button works
        	setLocationRelativeTo(null);//creates GUI in center of screen
        	
        	JLayeredPane content = new JLayeredPane();
        	content.setLayout(new BorderLayout());
        	
        	JPanel north = new JPanel();
        	north.setLayout(new GridLayout(1,3));
        	content.add(north, BorderLayout.NORTH);
        	
        	JPanel center = new JPanel();
        	center.setLayout(new GridLayout(2,6));
        	content.add(center, BorderLayout.CENTER);
        	
        	JPanel south = new JPanel();
        	south.setLayout(new GridLayout(1,3));
        	content.add(south, BorderLayout.SOUTH);
        	
        	JTextField taggerID = new JTextField ("Tagger ID");
        	JLabel lastName = new JLabel ("Last Name");
        	JLabel firstName = new JLabel ("First Name");
        	JLabel dailyLabel = new JLabel ("Dist. Daily:");
        	JLabel weeklyLabel = new JLabel ("Weekly:");
        	JLabel seasonalLabel = new JLabel ("Seasonal:");
        	JLabel daily = new JLabel ("0", JLabel.CENTER);
        	JLabel weekly = new JLabel("0", JLabel.CENTER);
        	JLabel seasonal = new JLabel("0", JLabel.CENTER);
        	JLabel ldsold = new JLabel("Sold Daily");
        	JLabel lwsold = new JLabel("Weekly");
        	JLabel lssold = new JLabel("Seasonal");
        	JTextField dsold = new JTextField("50", JLabel.CENTER);
        	JTextField wsold = new JTextField("25", JLabel.CENTER);
        	JTextField ssold = new JTextField("0", JLabel.CENTER);
        	JLabel lret = new JLabel("Returned     $");
        	JTextField ret = new JTextField("Amount calculated");
        	JLabel off = new JLabel("+/-");
        	
        	lastName.setForeground(Color.white);
        	firstName.setForeground(Color.white);
        	dailyLabel.setForeground(Color.white);
        	weeklyLabel.setForeground(Color.white);
        	seasonalLabel.setForeground(Color.white);
        	ldsold.setForeground(Color.white);
        	lwsold.setForeground(Color.white);
        	lssold.setForeground(Color.white);
        	lret.setForeground(Color.white);
        	off.setForeground(Color.white);
        	daily.setForeground(Color.white);
        	weekly.setForeground(Color.white);
        	seasonal.setForeground(Color.white);
        	
        	north.add(taggerID);
        	north.add(lastName);
        	north.add(firstName);
        	center.add(dailyLabel);
        	center.add(daily);
        	center.add(weeklyLabel);
        	center.add(weekly);
        	center.add(seasonalLabel);
        	center.add(seasonal);
        	center.add(ldsold);
        	center.add(dsold);
        	center.add(lwsold);
        	center.add(wsold);
        	center.add(lssold);
        	center.add(ssold);
        	south.add(lret);
        	south.add(ret);
        	south.add(off);
        	
        	content.setBackground(Color.blue);
        	south.setBackground(Color.blue);
        	center.setBackground(Color.blue);
        	north.setBackground(Color.blue);
    	}
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Since it is not part of standard Java, I have to ask: What exactly is a JDrawPanel? Also, you may wish to create and post a paragraph describing in greater detail what you're trying to do.

    edit: Also, I don't see where you're adding anything to the JFrame or its contentPane, so nothing will be visible. Also, I think that JLayeredPanes typically use no layout managers (null), but I could be wrong on this point.
    Last edited by Fubarable; 10-04-2009 at 12:23 AM.

Similar Threads

  1. panes, frames and ddm's :|
    By skatefreak in forum New To Java
    Replies: 1
    Last Post: 08-09-2009, 11:21 AM
  2. transparent gifs and layered panels
    By infinity in forum AWT / Swing
    Replies: 0
    Last Post: 05-01-2009, 09:52 PM
  3. GUI Help(Layered panes, opacity, events)
    By xcallmejudasx in forum New To Java
    Replies: 1
    Last Post: 04-30-2009, 12:11 AM
  4. Layered Pane Demo
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-26-2008, 08:44 PM
  5. Two content panes in one GUI?
    By Leprechaun in forum New To Java
    Replies: 1
    Last Post: 01-31-2008, 05:02 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •