Results 1 to 5 of 5

Thread: JPanel class of java

  1. #1
    Join Date
    Dec 2009
    Posts
    38

    JPanel class of java

    Hello friend,

    I am beginner in the field of advanced java programming. I am totally confused about the JPanel class of java programming language. I don't have any idea about the use of JPanel class. I have referred various websites for this but didn't get proper details. Do have enough knowledge about the JPanel class of java? If yes then please let me know that along with suitable example for it. I am waiting for your reply.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: JPanel class of java

    Hi,

    A JPanel class of java is also referred as lightweight container. A JPanel class basically implements MenuContainer, Serializable, Accessible, ImageObserver these interfaces. A JPanel class odd java is originally taken from the java package known as 'javax.swing.JComponent'. Thre are two subclasses are available with JPanel class and which are JSpinner.DefaultEditor & AbstractColorChooserPanel.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: JPanel class of java

    Please refer following example of the JPanel class of java. In this example I uases isFocusCycleRoot() method of JPanel class:
    Code:
    import javax.swing.JPanel;
    
    public class JPaneldm {
      public static void main(String args[]) {
        JFrame frame03 = new JFrame("Focus Cycle Sample");
    
        Container contentPane = frame03.getContentPane();
        contentPane.setLayout(new GridLayout(3,3));
        for (int i = 0; i < 8; i++) {
          JButton button02 = new JButton("" + i);
          contentPane.add(button02);
        }
        JPanel panel01 = new FocusCycleConstrainedJPanel();
        panel01.setLayout(new GridLayout(1, 3));
        for (int i = 0; i < 3; i++) {
          JButton button02 = new JButton("" + (i + 3));
          panel01.add(button02);
        }
        contentPane.add(panel01);
        frame03.setSize(400, 200);
        frame03.setVisible(true);
      }}
    
    class FocusCycleConstrainedJPanel extends JPanel {
      public boolean isFocusCycleRoot() {
        return true;
      }
    }

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: JPanel class of java

    Hi friend,

    Below are some method as well as the constructors of JPanel class of java. These methods and constructors are used to access the properties of JPanel class:
    1. JPanel(LayoutManager lyt, boolean DoubleBuffered)
    2. JPanel(LayoutManager lyt)
    3. JPanel()
    4. JPanel(boolean DoubleBuffered)
    5. setUI(PanelUI pui)
    6. getAccessibleContext()
    7. getUIClassID()

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: JPanel class of java

    Hello friend,

    I suggets yout to study follwing example of JPanel class. This java example will show you the use of JPanel class:
    Code:
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
    
    public class JPdemo extends JPanel {
    
      public MainClass() {
        JRadioButton radMarriedYes1 = new JRadioButton("Yes?", true);
        JRadioButton radMarriedNo1 = new JRadioButton("No?", false);
        
        ButtonGroup radioGroup01 = new ButtonGroup();
         setLayout(null);
    
        add(radMarriedYes1);
        add(radMarriedNo1);
    
        radioGroup01.add(radMarriedYes1);
        radioGroup01.add(radMarriedNo1);
    
        radMarriedYes1.setBounds(40, 50, 50, 20);
        radMarriedNo1.setBounds(40, 80, 50, 20);
      }
      public static void main(String[] args) {
        JFrame frame2 = new JFrame();
        frame2.getContentPane().add(new MainClass());
    
        frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame2.setSize(200, 200);
        frame2.setVisible(true);
      }
    }

Similar Threads

  1. Converting java class to java bean class
    By Ucchal in forum Software Development
    Replies: 6
    Last Post: 09-08-2010, 10:24 AM
  2. Dimension class of java
    By Gokul20 in forum Software Development
    Replies: 5
    Last Post: 25-02-2010, 08:02 AM
  3. How to use RandomAccessFile class in java?
    By Migueel in forum Software Development
    Replies: 4
    Last Post: 03-02-2010, 10:32 PM
  4. Help: Java swing JPanel to repaint PaintComponent( Graphics g )
    By grudge in forum Software Development
    Replies: 4
    Last Post: 22-07-2009, 07:05 PM
  5. Java Programming Language Basics: Reflection Basics and Class Class
    By mayuri_gunjan in forum Guides & Tutorials
    Replies: 6
    Last Post: 29-08-2005, 12:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,210,762.36164 seconds with 17 queries