Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: PUTTING JSCROLLPANE INSIDE JFRAME

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question PUTTING JSCROLLPANE INSIDE JFRAME

    Whenever I put Jscrollpane on the Jframe, the components that I already made was disappearing. What should I do to make my codes that I already put to appear inside the JFrame as well as with the JScrollpane. Sorry for my bad English. BTW, here's my codes.
    import java.awt.*;
    import java.awt.FlowLayout;
    import javax.swing.*;
     
    public class MaxsFriedChicken extends JFrame{
     
     
        JLabel title, fdname1, fdname2, prc1, prc2, qty1, qty2;
        JLabel img1, img2, img3, img4, img5;
        JLabel info1, info2, info3, info4, info5, info6, info7, info8, info9, info10;
        JTextField qtty1, qtty2, qtty3;
        JButton add1, add2, add3, add4, add5;
        JScrollPane scroll = new JScrollPane();
     
        public MaxsFriedChicken(){
     
            title = new JLabel ("MAX's MENU");
            getContentPane().add(title);
            title.setBounds(350,0,300,50);
            title.setFont(new Font("Broadway", Font.PLAIN,35));
    		title.setForeground(Color.black);
     
    		fdname1 = new JLabel ("Regular Fried Chicken");
    		getContentPane().add(fdname1);
            fdname1.setBounds(300,100,350,50);
            fdname1.setFont(new Font("Bradley Hand ITC", Font.BOLD,22));
    		fdname1.setForeground(Color.black);
     
    		img1 = new JLabel (new ImageIcon("Max's Fried Chicken2.jpg"));
    		getContentPane().add(img1);
    		img1.setBounds(20,40,300,300);
     
    		info1 = new JLabel ("The original, classic fried chicken that made Max's popular. It");
    		getContentPane().add(info1);
            info1.setBounds(300,130,550,50);
            info1.setFont(new Font("Bradley Hand ITC", Font.PLAIN,20));
    		info1.setForeground(Color.black);
     
    		info2 = new JLabel("is cooked to golden perfection, processed in a very unique way");
    		getContentPane().add(info2);
            info2.setBounds(300,150,550,50);
            info2.setFont(new Font("Bradley Hand ITC", Font.PLAIN,20));
    		info2.setForeground(Color.black);
     
    		info3 = new JLabel("which gives this product the unforgettable sarap to the bones ");
    		getContentPane().add(info3);
            info3.setBounds(300,170,550,50);
            info3.setFont(new Font("Bradley Hand ITC", Font.PLAIN,20));
    		info3.setForeground(Color.black);
     
    		info4 = new JLabel("quality, spiced just right and totally MSG-free.");
    		getContentPane().add(info4);
            info4.setBounds(300,190,550,50);
            info4.setFont(new Font("Bradley Hand ITC", Font.PLAIN,20));
    		info4.setForeground(Color.black);
     
    		prc1 = new JLabel ("Price: PH 400.00");
    		getContentPane().add(prc1);
            prc1.setBounds(320,230,300,50);
            prc1.setFont(new Font("Britannic Bold", Font.PLAIN,18));
            prc1.setForeground(Color.black);
     
    		qty1 = new JLabel ("Quantity:");
    		getContentPane().add(qty1);
            qty1.setBounds(500,230,300,50);
            qty1.setFont(new Font("Britannic Bold", Font.PLAIN,18));
            qty1.setForeground(Color.black);
     
    		qtty1 = new JTextField ("");
    		getContentPane().add(qtty1);
            qtty1.setBounds(580,235,40,30);
            qtty1.setFont(new Font("Britannic Bold", Font.PLAIN,18));
            qtty1.setForeground(Color.black);
     
            add1 = new JButton ("Add To Tray");
            getContentPane().add(add1);
            add1.setBounds(650,235,130,30);
            add1.setBackground(Color.black);
            add1.setForeground(Color.red);
     
    		img2 = new JLabel (new ImageIcon("Family Chicken Basket.jpg"));
    		getContentPane().add(img2);
    		img2.setBounds(20,300,300,300);
     
    		fdname2 = new JLabel ("Family Chicken Basket");
    		getContentPane().add(fdname2);
            fdname2.setBounds(300,350,350,50);
            fdname2.setFont(new Font("Bradley Hand ITC", Font.BOLD,22));
    		fdname2.setForeground(Color.black);
     
    		info5 = new JLabel("8 pieces of favorite Max's fried chicken (leg and thigh parts)");
    		getContentPane().add(info5);
            info5.setBounds(300,380,550,50);
            info5.setFont(new Font("Bradley Hand ITC", Font.PLAIN,20));
    		info5.setForeground(Color.black);
     
    		info6 = new JLabel("cooked to an unmatched perfection to satisfy the guests' craving.");
    		getContentPane().add(info6);
            info6.setBounds(300,400,550,50);
            info6.setFont(new Font("Bradley Hand ITC", Font.PLAIN,20));
    		info6.setForeground(Color.black);
     
    		info7 = new JLabel("This is still the original and classic fried chicken that");
    		getContentPane().add(info7);
            info7.setBounds(300,420,550,50);
            info7.setFont(new Font("Bradley Hand ITC", Font.PLAIN,20));
    		info7.setForeground(Color.black);
     
    		info8 = new JLabel("made Max's world famous and a Filipino institution. Golden");
    		getContentPane().add(info8);
            info8.setBounds(300,440,550,50);
            info8.setFont(new Font("Bradley Hand ITC", Font.PLAIN,20));
    		info8.setForeground(Color.black);
     
    		info9 = new JLabel("fried to perfection with a unique blend of secret spices.");
    		getContentPane().add(info9);
            info9.setBounds(300,460,550,50);
            info9.setFont(new Font("Bradley Hand ITC", Font.PLAIN,20));
    		info9.setForeground(Color.black);
     
    		prc2 = new JLabel ("Price: PH 500.00");
    		getContentPane().add(prc2);
            prc2.setBounds(320,500,300,50);
            prc2.setFont(new Font("Britannic Bold", Font.PLAIN,18));
            prc2.setForeground(Color.black);
     
    		qty2 = new JLabel ("Quantity:");
    		getContentPane().add(qty2);
            qty2.setBounds(500,500,300,50);
            qty2.setFont(new Font("Britannic Bold", Font.PLAIN,18));
            qty2.setForeground(Color.black);
     
    		qtty2 = new JTextField ("");
    		getContentPane().add(qtty2);
            qtty2.setBounds(580,505,40,30);
            qtty2.setFont(new Font("Britannic Bold", Font.PLAIN,18));
            qtty2.setForeground(Color.black);
     
           	add2 = new JButton ("Add To Tray");
            getContentPane().add(add2);
            add2.setBounds(650,505,130,30);
    		add2.setBackground(Color.black);
    		add2.setForeground(Color.red);
     
            add3 = new JButton ("Add To Tray");
            getContentPane().add(add3);
            add3.setBounds(40,330,130,30);
     
            add4 = new JButton ("Add To Tray");
            getContentPane().add(add4);
            add4.setBounds(40,330,130,30);
     
            add5 = new JButton ("Add To Tray");
            getContentPane().add(add5);
            add5.setBounds(40,330,130,30);
     
     
    		 JPanel pane = new JPanel();
    		getContentPane().add(pane);
    		pane.setBounds(50,150,300,400);
    		pane.setBackground(Color.red);
    		pane.setLayout(null);
    		pane.setBorder(BorderFactory.createLineBorder(Color.black));
     
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
        }
     
    	public static void main (String[] args) {
     
            MaxsFriedChicken fL = new MaxsFriedChicken();
            fL.setTitle ("Max's Restaurant");
            fL.setVisible (true);
            fL.setResizable (false);
            fL.setBounds (150,1,1000,700);
     
        }
     
    }
    Last edited by JavaPF; September 15th, 2011 at 09:19 AM. Reason: Use highlight or code tags!!


Similar Threads

  1. reversing text in a file then putting it to a new file
    By derekxec in forum What's Wrong With My Code?
    Replies: 14
    Last Post: July 9th, 2011, 10:36 PM
  2. Need help putting GUI in program!
    By greyfox175 in forum AWT / Java Swing
    Replies: 5
    Last Post: May 4th, 2011, 09:55 PM
  3. painting Image on JPanel inside a JScrollPane
    By becca23 in forum AWT / Java Swing
    Replies: 1
    Last Post: September 29th, 2010, 08:28 PM
  4. Reading a file, then putting it in an array
    By Gondee in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 16th, 2010, 12:11 PM
  5. Putting text fields in an array
    By Movies32 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 10th, 2010, 07:46 PM