JPanel and Class

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: JPanel and Class

  1. #1
    Join Date
    Dec 2007

    Lightbulb JPanel and Class

    as a complete newbe I have a question about Graphics.
    I have a package with a frmStartForm and a class DrawSomething in it.
    I have a frmStartForm with a jPanel_1 on it.
    I wrote a new Class named Design, with a methode DrawSomething in it.

    public void DrawSomething(){

    I make in the frmStarForm a new instance from the Design class

    Design design = new Design;

    so far so good.

    But if I write in the frmStartForm (call the method)

    nothing will happens, unless some errors appears.
    I've did try all way's to draw something from out my class, but no way, I give up, unless someone can give me an understandble hint, as I said, I'm a complete newbe, and my experiance is that some people will give a helping hand, but speak in riddles.

  2. #2
    Join Date
    Feb 2007
    if I understand well ur question..
    you may try to create ur own panel extending from JPanel and using the paintComponent methode :
    class ur_panel extends JPanel{
    public void paintComponent(Graphics g){
    super.paintComponent(Graphics g); // to call the parent methode>>ofJPanel

    //I have tryed just some few figure like a line a cercle or an rectangle
    //for exemple to draw a simple line:
    g.drawLine(15,10,100,15); // setting bounds
    ur_panel p=new ur_panel();

    i have never used a String ....just seacrh all the Graphics methode( drawline,drawOvale,...u may find somthg about strings)...

    good luck

Similar Threads

  1. Replies: 3
    Last Post: 07-26-2007, 03:46 PM
  2. Byte Problems
    By Rmstn1580 in forum Java
    Replies: 2
    Last Post: 01-07-2007, 11:54 PM
  3. Row not showing
    By Rmstn1580 in forum Java
    Replies: 0
    Last Post: 12-19-2006, 08:10 PM
  4. Problem with inner class
    By IronJack in forum Java
    Replies: 12
    Last Post: 08-08-2006, 06:52 PM
  5. JAVA help
    By Munchkin in forum Java
    Replies: 3
    Last Post: 03-16-2001, 04:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center