Results 1 to 5 of 5
  1. #1
    Azndaddy is offline Member
    Join Date
    Mar 2008
    Posts
    24
    Rep Power
    0

    Default [SOLVED] Help with JPanel

    Ok, i just need some help on JPanel

    At the moment i have the following code, but am not to sure if its correct or not.

    The code is
    PHP Code:
    import javax.swing.*;
    import java.awt.*;
    
    public class BufButPanel extends JPanel 
    {
        private Buf buf;
        private JButton sButton;
        private JButton rButton;
    
        public BufButPanel(Buf buf)
        {
            this.buf = buf;
    
            sButton = new JButton("Save");
            add(sButton);
            
            rButton = new JButton("Revert");
            add(rButton);
            
        }
    }
    How do i go about in setting it up as a controller for each of the button, and to test if the button are showing, eg open up a new window with the button

    Thanks

  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    You can start to read ActionListeners with more details that can be found here.

    Take a look at JButton Class
    freedom exists in the world of ideas

  3. #3
    Azndaddy is offline Member
    Join Date
    Mar 2008
    Posts
    24
    Rep Power
    0

    Default

    Ok, i have gone through the site and had a look, just another question

    How do i put a JPanel class into a JFrame class

    EG. I have JPanel class for Buttons (buttons of say, new, open, exit), and a JPanel class for TextArea(text area that can be use to type in text)

    I want to call both of the JPanel class into a JFrame class (a Empty Frame with only File menu, edit menu and Help menu).

    I'm having difficultie in trying to call them in

  4. #4
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Create an object from those Classes
    Add that object to the JFrame

    eg. add(Component c) method
    freedom exists in the world of ideas

  5. #5
    Azndaddy is offline Member
    Join Date
    Mar 2008
    Posts
    24
    Rep Power
    0

Similar Threads

  1. refresh JPanel
    By olesja in forum AWT / Swing
    Replies: 1
    Last Post: 04-16-2008, 04:58 PM
  2. Genarate JPanel
    By Bill in forum AWT / Swing
    Replies: 6
    Last Post: 03-24-2008, 08:38 PM
  3. Problem with JPanel
    By ibanez270dx in forum New To Java
    Replies: 2
    Last Post: 11-09-2007, 06:04 PM
  4. JPanel Problems
    By Riftwalker in forum AWT / Swing
    Replies: 6
    Last Post: 10-16-2007, 12:16 AM
  5. Draw on JPanel, Help
    By carl in forum Java 2D
    Replies: 1
    Last Post: 07-31-2007, 07:56 AM

Posting Permissions

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