Java JLayeredPane

Java JLayeredPane

How to Declare Java JLayeredPane
Java JLayeredPane is used to add the third dimension for positioning or dividing component into several layers.

How to Declare Java JLayeredPane

[class JLayeredPane extends JComponent implements Accessible
 
 
]

Java JLayeredPane constructors

JLayeredPane-used to create a new JLayeredPane.

Java JLayeredPane Methods

  • int getIndexOf(Component c)-used to return certain component index that is selected.
  • int getLayer(Component c)-this method is used to return attribute layer.
  • int getPosition(Component c)-return component position in it layer.

Java JLayeredPane Example

[
import java.awt.Color;
import javax.swing.JLayeredPane;
import javax.swing.JFrame;
import javax.swing.JButton;


public class JavaJlayeredPaneExample extends JFrame {
    public JLayeredPane pane;
    JavaJlayeredPaneExample()
    {
        super("JavaJlayeredPaneExample");
        setSize(400,400);
        pane=getLayeredPane();
        JButton button1=new JButton("Button 1");
        button1.setBackground(Color.red);
        button1.setBounds(10,10, 200, 30);
        pane.add(button1,new Integer(1));
        JButton button2=new JButton("Button 2");
        button2.setBackground(Color.BLUE);
        button2.setBounds(30, 60, 200, 30);
        pane.add(button2,new Integer(2));
        JButton button3=new JButton("Button 3");
        button3.setBounds(50, 120, 200, 30);
        button3.setBackground(Color.CYAN);
        pane.add(button3,new Integer(3));
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);

    }
    public static void main(String args[])
    {
        new JavaJlayeredPaneExample().setVisible(true);
    }
}
]

Java JLayeredPane with ActionListener Example

[
import java.awt.Color;
import javax.swing.JLayeredPane;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JColorChooser;


public class JavaJlayeredPaneExample extends JFrame
        implements ActionListener{
    public JLayeredPane pane;
    public  JButton button1,button2,button3;
    JavaJlayeredPaneExample()
    {
        super("JavaJlayeredPaneExample");
        setSize(400,400);
        pane=getLayeredPane();
        button1=new JButton("Button 1");
        button1.setBackground(Color.red);
        button1.setBounds(10,10, 200, 30);
        button1.addActionListener(this);
        pane.add(button1,new Integer(1));
        button2=new JButton("Button 2");
        button2.setBackground(Color.BLUE);
        button2.addActionListener(this);
        button2.setBounds(30, 60, 200, 30);
        pane.add(button2,new Integer(2));
        button3=new JButton("Button 3");
        button3.setBounds(50, 120, 200, 30);
        button3.addActionListener(this);
        button3.setBackground(Color.CYAN);
        pane.add(button3,new Integer(3));

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);

    }
    public void actionPerformed(ActionEvent event)
    {
        if(event.getSource()==button1)
        {
            Color c=JColorChooser.showDialog(this,"Select Color", Color.yellow);
            button1.setBackground(c);
        }
        else if(event.getSource()==button2)
        {
            Color c=JColorChooser.showDialog(this,"Select Color", Color.yellow);
            button2.setBackground(c);
        }

        else   if(event.getSource()==button3)
        {
            Color c=JColorChooser.showDialog(this,"Select Color", Color.yellow);
            button3.setBackground(c);
        }
    }
    public static void main(String args[])
    {
        new JavaJlayeredPaneExample().setVisible(true);
    }
}
]

Java JLayeredPane with ActionListener Example


Related Tutorials:


COMMENTS

Name

android android Apps android emulators antivirus blogger bluestack Break Statement in Java constructors download downloader drivers emulators java java control statements java do-while loop java for loop java infinitive do-while loop java system methods java tutorials Java While Loop java.awt java.swing javalookandfeel javascript JButton JCheckBox JColorChooser JComboBox JDialog JFileChooser JFrame JLayeredPane JList JMenuBar joomla JOptionPane JPanel JPasswordField JPopupMenu JProgressBar JRadioButton JScrollBar JSlider JSpinner JTabbedPane JTable JTextArea JTextField JToolBar mysql php plugins Polymorphism setToolTiptext skype for windows software swing class themes Visual Studio Code WeChat whatsapp wordpress
false
ltr
item
Java Codes: Java JLayeredPane
Java JLayeredPane
Java JLayeredPane
https://2.bp.blogspot.com/-IxgIwESq_Uw/WO-tYuP0IqI/AAAAAAAAHlc/x_pXti60vwEOBpoCHDxDT7xHpCgTwoT8wCLcB/s320/java-JlayeredPane-example-min.PNG
https://2.bp.blogspot.com/-IxgIwESq_Uw/WO-tYuP0IqI/AAAAAAAAHlc/x_pXti60vwEOBpoCHDxDT7xHpCgTwoT8wCLcB/s72-c/java-JlayeredPane-example-min.PNG
Java Codes
http://www.download-all.net/2017/04/java-jlayeredpane.html
http://www.download-all.net/
http://www.download-all.net/
http://www.download-all.net/2017/04/java-jlayeredpane.html
true
7826648292785071009
UTF-8
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy