Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2006

Tip: Looking for answers? Try searching our database.

JPanel , JScrollpane ,Painting Please help

Thread view: 
Foolad - 26 Jul 2006 14:05 GMT
Please help me.
I have trie many way sbut neither of them worked.
I have a class that extends JPanel and I want to paint something on it.

public class MyPanel extends JPanel {
    public MyPanel() {
        // TODO Auto-generated constructor stub
        super();
        this.setSize(20000,20000);
    }
@Override
public void paint(Graphics g) {
    // TODO Auto-generated method stub
    super.paintComponents(g);
    g.drawLine(0,0,1000,1000);
}
}
Now I put that in a JScrollpane to be able to see all the paintings.But
JSCrollpane doesn't show any scrollbars and many parts remain hidden.
What should I do? please show mw the code that works.
Thanks in advance a lot.
Michael Rauscher - 26 Jul 2006 16:27 GMT
Foolad schrieb:
> Please help me.
> I have trie many way sbut neither of them worked.
[quoted text clipped - 16 lines]
> JSCrollpane doesn't show any scrollbars and many parts remain hidden.
> What should I do? please show mw the code that works.

    public class MyPanel extends JPanel {
        public Dimension getPreferredSize() {
            return new Dimension(800,800);
        }

        public void paintComponent( Graphics g ) {
            super.paintComponent( g );
            g.drawLine(0,0,800,800);
        }
    }

Bye
Michael


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.