Results 1 to 9 of 9
  1. #1
    kumar.dinesh7 is offline Member
    Join Date
    May 2012
    Location
    Yamuna Nagar,Haryana,India
    Posts
    28
    Rep Power
    0

    Question how to make java applet scrollable??

    i am drawing some component like rectangles on the applet window.....if i draw the component below the visible screen then applet window doesn't show that components.....how can i scroll the applet so that i can see below the visible screen by scrolling....??

    i am using NETBEANS IDE for developing Applets.

    Plz help me...
    Last edited by kumar.dinesh7; 09-19-2012 at 05:20 PM.
    dk

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: how to make java applet scrollable??

    I've given you the link to the Oracle Swing tutorials at least twice before. If you were genuinely interested in learning, you would have had more than enough time to go through the entire tutorial trail and wouldn't still be asking silly questions.

    I'll add that the NetBeans visual designer is categorically NOT a beginners' tool. Learn to hand-code GUIs first.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    kumar.dinesh7 is offline Member
    Join Date
    May 2012
    Location
    Yamuna Nagar,Haryana,India
    Posts
    28
    Rep Power
    0

    Default Re: how to make java applet scrollable??

    okay
    dk

  5. #5
    kumar.dinesh7 is offline Member
    Join Date
    May 2012
    Location
    Yamuna Nagar,Haryana,India
    Posts
    28
    Rep Power
    0

    Default Re: how to make java applet scrollable??

    Java Code:
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    
    
    class applet_opr extends Applet
    {
        public void init()
                
        {      
            setBackground(Color.red);
        }
        
        public void paint(Graphics g)
        {
            g.drawRect(100, 100, 1200, 900);
        }
    }
    
    
    public class practical
    {
        
    public static void main(String[]args)
    {
        
    applet_opr pa=new applet_opr();
    pa.init();
    
    JScrollPane scrollBar=new JScrollPane(pa,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    
    
    JFrame frame=new JFrame("AddScrollBarToJFrame");
    
    frame.setLayout(new BorderLayout());
    frame.add(scrollBar);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(1000,700);
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.setVisible(true);
    
    }
    }


    i tried this code....this code makes a scroll bar but scroll bar not working.
    Last edited by kumar.dinesh7; 09-20-2012 at 05:20 PM.
    dk

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: how to make java applet scrollable??

    Find the tutorial on developing and deploying Applets and go through the section that deals with the Applet life cycle.

    Also, don't unnecessarily mix AWT and Swing components. Why do you think you need to use an Applet for this code?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: how to make java applet scrollable??

    Additionally, I repeat my recommendation to go through the Swing tutorial systematically. Nothing in that code suggests that the scroll pane's content is larger than the viewport, so why should the scroll bars be active?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  8. #8
    kumar.dinesh7 is offline Member
    Join Date
    May 2012
    Location
    Yamuna Nagar,Haryana,India
    Posts
    28
    Rep Power
    0

    Default Re: how to make java applet scrollable??

    okay....can you provide me a better link where i can learn all this?
    dk

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: how to make java applet scrollable??

    Not better than the one already given, no.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Make applet run outside editor
    By Maarten in forum New To Java
    Replies: 4
    Last Post: 07-29-2012, 05:04 PM
  2. Replies: 16
    Last Post: 03-21-2012, 09:41 AM
  3. Replies: 1
    Last Post: 03-03-2012, 09:35 PM
  4. scrollable applets
    By kaemonsaionji in forum New To Java
    Replies: 2
    Last Post: 02-25-2009, 08:47 AM
  5. Make java applet a button
    By hervey in forum New To Java
    Replies: 31
    Last Post: 10-30-2008, 05:44 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
  •