Results 1 to 3 of 3
  1. #1
    larry_d1990 is offline Member
    Join Date
    Jan 2011
    Rep Power

    Default Extend JFrame : JPanel Drawing Area

    Basically, this is for an assignment so I can't give too much coding...

    I've got a class that extends JFrame, I've inserted a JPanel into the frame and a JTextArea. I want to only be able to draw within the panel and not on the textarea aswell. Help me!! :(

    Here's some of my example coding...

    public class GUI extends JFrame {

    private JPanel panelG;

    private JTextArea fileS;

    public GUI()


    private class LinePanel extends JPanel
    public void paintComponent(Graphics g) {
    g.drawLine(50, 70, 80, 70);




  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Rep Power


    Assuming that panelG has been added to GUI, and that fileS has been added to panelG, and assuming panelG is a LinePanel, then it should already be doing what you said. What's not working?

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power


    To get better help sooner, post a SSCCE that clearly demonstrates your problem.


Similar Threads

  1. Capturing the drawing area
    By George R. in forum Java 2D
    Replies: 7
    Last Post: 10-21-2010, 07:04 PM
  2. Drawing on Jpanel
    By nonabhai in forum AWT / Swing
    Replies: 0
    Last Post: 03-13-2010, 05:46 AM
  3. Drawing with JPanel
    By m00nchile in forum New To Java
    Replies: 2
    Last Post: 02-18-2010, 09:12 PM
  4. drawing in JPanel ,beyond the co-ordinates
    By anandnarayan891 in forum AWT / Swing
    Replies: 4
    Last Post: 04-05-2009, 03:42 AM
  5. drawing to a JPanel
    By diggitydoggz in forum New To Java
    Replies: 11
    Last Post: 03-09-2009, 08:42 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