Advertisement
apl-mhd

windowToogle

Dec 21st, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.66 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.awt.*;
  4. import javax.swing.*;
  5. public class PanelExample {
  6.     PanelExample()
  7.     {
  8.         JFrame f= new JFrame("Panel Example");
  9.         /*JPanel panel=new JPanel();
  10.  
  11.         panel.setLayout(new GridLayout(3,2));
  12.         panel.setBounds(0,0,200,200);
  13.         panel.setBackground(Color.gray);
  14.         JButton b1=new JButton("Button 1");
  15.         b1.setBounds(50,100,80,30);
  16.         b1.setBackground(Color.yellow);
  17.         JButton b2=new JButton("Button 2");
  18.         b2.setBounds(100,100,80,30);
  19.         b2.setBackground(Color.green);
  20.         panel.add(b1); panel.add(b2);
  21.         */
  22.  
  23.  
  24.         //f.removeAll();
  25.         f.add(new PanelDesign().homePage());
  26.         f.setSize(400,400);
  27.         f.setLayout(null);
  28.         f.setVisible(true);
  29.     }
  30.     public static void main(String args[])
  31.     {
  32.         new PanelExample();
  33.     }
  34. }
  35.  
  36.  
  37.  
  38. package com.company;
  39.  
  40. import javax.swing.*;
  41. import java.awt.*;
  42. import java.awt.event.ActionEvent;
  43. import java.awt.event.ActionListener;
  44.  
  45. public  class  PanelDesign implements ActionListener {
  46.  
  47.     @Override
  48.     public void actionPerformed(ActionEvent e) {
  49.  
  50.     }
  51.  
  52.     JPanel overLoad(JPanel ob){
  53.  
  54.  
  55.         return ob;
  56.     }
  57.  
  58.  
  59.  
  60.     static JPanel  nextPage(){
  61.  
  62.         JPanel panel=new JPanel();
  63.  
  64.  
  65.         panel.setLayout(new GridLayout(3,2));
  66.         panel.setBounds(0,0,200,200);
  67.         panel.setBackground(Color.gray);
  68.         JButton b1=new JButton("BackPage");
  69.  
  70.         b1.addActionListener(new ActionListener() {
  71.             @Override
  72.             public void actionPerformed(ActionEvent e) {
  73.  
  74.  
  75.                 new PanelDesign().homePage();
  76.             }
  77.         });
  78.  
  79.         b1.setBounds(50,100,80,30);
  80.         b1.setBackground(Color.yellow);
  81.         JButton b2=new JButton("Button 2");
  82.         b2.setBounds(100,100,80,30);
  83.         b2.setBackground(Color.green);
  84.         panel.add(b1); panel.add(b2);
  85.  
  86.  
  87.         return panel;
  88.  
  89.     }
  90.  
  91.  
  92.     JPanel homePage(){
  93.  
  94.         JPanel panel=new JPanel();
  95.  
  96.  
  97.         panel.setLayout(new GridLayout(3,2));
  98.         panel.setBounds(0,0,200,200);
  99.         panel.setBackground(Color.gray);
  100.         JButton b1=new JButton("Next");
  101.  
  102.         b1.addActionListener(new ActionListener() {
  103.             @Override
  104.             public void actionPerformed(ActionEvent e) {
  105.               new PanelDesign().nextPage();
  106.             }
  107.         });
  108.  
  109.         b1.setBounds(50,100,80,30);
  110.         b1.setBackground(Color.yellow);
  111.         JButton b2=new JButton("Button 2");
  112.         b2.setBounds(100,100,80,30);
  113.         b2.setBackground(Color.green);
  114.         panel.add(b1); panel.add(b2);
  115.  
  116.  
  117.         return panel;
  118.  
  119.     }
  120.  
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement