Hey all,

My program creates panels with textfields. The actual goal is to draw lines between the textfields. But i'm stuck way before that stage. I can draw lines with the button connection lines and you click on two points and it draws a line. The 2 problems I have are:

1. The panels with textfields disappear when I draw a line, and they shouldn't.
2. Even though I create an array such that I can draw many lines, the previous line disappears when I draw a new one.

I think it's got to do something with the repaint() method but I don't know how to fix it..

Thanks for your help/advice!

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.io.*;

public class Try8 extends JFrame implements MouseListener

{
  
 

  public int i=0;
  public int k=10;
  public int b=20;
  public int m=-1;
  public int c=1;
  public int d=0;
  public int f=0;
  public int a =0;

  public int x;
  public int y;
  public int z=0;
  


  public JPanel [] panel= new JPanel[31];
  public JTextField [] text=new JTextField[16];
  public  ConnectionLines [] cl = new ConnectionLines[50];
  public int [] xvalues = new int [50];
  public int [] yvalues = new int [50];

  public int [] cnt= new int [3];
  
  public Try8()
 {


 JPanel p = new JPanel();
 p.setLayout(new GridLayout(6,1, 5, 5));
 
  JButton b1 = new JButton("input space");
  JButton b2 = new JButton("generic space");
  JButton b3 = new JButton("blend space");
  JButton b4 = new JButton("remove textfield");
  JButton b5 = new JButton("textfield");
  JButton b6 = new JButton("connection line");

  

  p.add(b1);
  p.add(b2);
  p.add(b3);
  p.add(b4);
  p.add(b5);
  p.add(b6);


  add(p, BorderLayout.WEST);

 final JPanel q = new JPanel();
 q.setLayout(new BorderLayout());
 final JPanel r = new JPanel();
 final JPanel s = new JPanel();
 final JPanel t = new JPanel();
 

 add(q, BorderLayout.CENTER);
 q.add(r, BorderLayout.CENTER);
 q.add(s, BorderLayout.EAST);
 q.add(t, BorderLayout.SOUTH);
  

  for (i=0; i<=30; i++)
  {
  panel[i]=new JPanel();
  panel[i].addMouseListener(this);
  panel[i].setName("" + i);
  }
  
  i=0;
        cnt[0]=-1;
        cnt[1]=-1;
        cnt[2]=-1;
        

  b1.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
    d=d+1;
    i=i+1;
    text[1]=new JTextField(10);

    
    
    r.add(panel[i]); 
    panel[i].setLayout(new GridLayout(1,1,6,5));
    
    panel[i].setBorder(new TitledBorder("input " + i));
   
    panel[i].add(text[1]);
    //panel[i].add(h);
  
   }
  });

 
 b2.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
    d=d+1;
    k=k+1;
    text[1]=new JTextField(10);
    
    s.add(panel[k]); 
    panel[k].setLayout(new GridLayout(1,1,6,5));
    
    panel[k].setBorder(new TitledBorder("generic " + (k-10)));
   
    panel[k].add(text[1]);
  
    
   }
  });
 

b3.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
    d=d+1;
    
    b=b+1;
    text[1]=new JTextField(10);
    
    t.add(panel[b]); 
    panel[b].setLayout(new GridLayout(1,1,6,5));
    
    panel[b].setBorder(new TitledBorder("blend "));
   
    panel[b].add(text[1]);
  
    
   }
  });
b4.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
     
     if (m==-1) {}
     else
     {
         
    c = panel[m].getComponentCount();
     
    if (c ==1) {}
    else
    {
     
      
     Component component = panel[m].getComponent(c-1);
     
    panel[m].remove(component);
    c = panel[m].getComponentCount();
     
    panel[m].setLayout(new GridLayout(c,1,6,5));
     
    validate();
     
    }
     }
   }
  }); 

b5.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
     

     if (m==-1) {}
     else
     {
            
      if (c==14) {}
      else
      {
     c = panel[m].getComponentCount();
 
     
     text[c+1]=new JTextField(10);
     
     
     panel[m].add(text[c+1]);

     c = panel[m].getComponentCount();
     
     
     panel[m].setLayout(new GridLayout(c,1,6,5));

     validate();
      }
     }     
    }
   });



b6.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
    
    f=f+1;
    cl[f] = new ConnectionLines();
    
    q.add(cl[f]);
   validate();

    
   }
  });


}



  public void mousePressed(MouseEvent e) 
  {}
  public void mouseReleased(MouseEvent e) 
  {}
  public void mouseEntered(MouseEvent e) 
  {}
  public void mouseExited(MouseEvent e) 
  {}
  public void mouseClicked(MouseEvent e) 
  {
     

   String name = e.getComponent().getName();
   m = Integer.parseInt(name);

   x = e.getX();
   y = e.getY();
   Point point= e.getPoint();
   point.translate(x, y);
System.out.println(name);
System.out.println("x is " + e.getX());
System.out.println("y is " + e.getY());
System.out.println(point);
System.out.println(x + " " + y);
   
   }



 
 public static void main(String args[])
   {
    Try8 frame = new Try8();

    frame.setTitle("let's try");
    frame.setSize (400, 400);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible (true);

     
   }
  
  public class ConnectionLines extends JPanel 
   {
    
    public ConnectionLines() 
    {
     
     addMouseListener(new MouseListener()
     {
      public void mouseClicked(MouseEvent e) 
      {
        if (z==2) 
        {
 	z=0;  
        }

        xvalues[a]=e.getX();
        yvalues[a]=e.getY();
	cnt[z]=1;
        
System.out.println(a);
System.out.println(xvalues[0]);
System.out.println(yvalues[0]);
System.out.println("");
System.out.println(xvalues[1]);
System.out.println(yvalues[1]);
System.out.println("");

            
	   repaint();
                   
      }
 public void mousePressed(MouseEvent e) 
  {}
  public void mouseReleased(MouseEvent e) 
  {}
  public void mouseEntered(MouseEvent e) 
  {}
  public void mouseExited(MouseEvent e) 
  {}
     });
    }
  
    protected void paintComponent( Graphics g) 
      {
	
       super.paintComponent(g);
       if((cnt[0] != -1) && (cnt[1] != -1))
       {
        g.drawLine(xvalues[a-1],yvalues[a-1],xvalues[a],yvalues[a]);
        cnt[0] = -1;
       }
       z=z+1;
       a=a+1;
      }
 
  }


 
}

You would make your life far easier if you used multiple JPanels to organize your components in to smaller groups and then add JPanels to JFrame in the layout you need...
In doing so you would may be need only one instance of JPanel with draw line in and you would just put it in different places

You would make your life far easier if you used multiple JPanels to organize your components in to smaller groups and then add JPanels to JFrame in the layout you need...
In doing so you would may be need only one instance of JPanel with draw line in and you would just put it in different places

but if I have only one JPanel with draw line and I put it in different places then I have only one line, right? I need several lines....

No, you will get as many lines as you wish, because of component re-use.

No, you will get as many lines as you wish, because of component re-use.

ok, so what I changed was change cl[f] = new ConnectionLines();
into cl= new ConnentionLines();

And i can draw several lines etc but I still have the problem that there is only one line present at the time and the panels disappear when i click on b6 which is the connection lines button.

I think the problem is that i add it to the panel but the BorderLayout will only allow 1 component in one position to be shown. Whereas I need the panels visible and on top of that the lines. Basically they should be sort "see through"
Do you know how to fix this?
here's my new code

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.io.*;

public class Try8 extends JFrame implements MouseListener

{
  
 

  public int i=0;  // input space panel[i]   (panel[0] - panel[10)
  public int k=10; // generic space panel[k] (panel[11] - panel[20])
  public int b=20; // blend space panel[b]   (panel[21] - panel[30])
  public int m=-1; // value m determines the panel 
  public int c=1;  // is set to number of components (textfields) on the panel[m]
  public int f=0;  // cl[f]= new ConnectionLines but I don't know why cl must be an array but otherwise it doesn't compile
  public int a =0; // used for xvalues[a] and yvalues[a] here the points are stored where the lines must be drawn

  public int x;    //used to get x value of panel, not actually used (yet) for anything in the program
                   //in the end lines should be drawn between the textfields but I don't know how to do that
  public int y;    //y = e.getY();
  public int z=0;  // makes sure that when drawing the line after the first click it only saves the x and y value 
                   // and after the second click it draws the line.
  


  public JPanel [] panel= new JPanel[31];
  public JTextField [] text=new JTextField[16];
  public  ConnectionLines [] cl = new ConnectionLines[50];
  public int [] xvalues = new int [50];
  public int [] yvalues = new int [50];

  public int [] cnt= new int [3];
  
  public Try8()
 {


 JPanel p = new JPanel();
 p.setLayout(new GridLayout(6,1, 5, 5));
 
  JButton b1 = new JButton("input space");
  JButton b2 = new JButton("generic space");
  JButton b3 = new JButton("blend space");
  JButton b4 = new JButton("remove textfield");
  JButton b5 = new JButton("textfield");
  JButton b6 = new JButton("connection line");

  

  p.add(b1);
  p.add(b2);
  p.add(b3);
  p.add(b4);
  p.add(b5);
  p.add(b6);


  add(p, BorderLayout.WEST);

 final JPanel q = new JPanel();
 q.setLayout(new BorderLayout());
 final JPanel r = new JPanel();
 final JPanel s = new JPanel();
 final JPanel t = new JPanel();
 

 add(q, BorderLayout.CENTER);
 q.add(r, BorderLayout.CENTER);
 q.add(s, BorderLayout.EAST);
 q.add(t, BorderLayout.SOUTH);
  

  for (i=0; i<=30; i++)
  {
  panel[i]=new JPanel();
  panel[i].addMouseListener(this);
  panel[i].setName("" + i);
  }
  
  i=0;
        cnt[0]=-1;
        cnt[1]=-1;
        cnt[2]=-1;
        

  b1.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
    
    i=i+1;
    text[1]=new JTextField(10);

    
    
    r.add(panel[i]); 
    panel[i].setLayout(new GridLayout(1,1,6,5));
    
    panel[i].setBorder(new TitledBorder("input " + i));
   
    panel[i].add(text[1]);
    //panel[i].add(h);
  
   }
  });

 
 b2.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
  
    k=k+1;
    text[1]=new JTextField(10);
    
    s.add(panel[k]); 
    panel[k].setLayout(new GridLayout(1,1,6,5));
    
    panel[k].setBorder(new TitledBorder("generic " + (k-10)));
   
    panel[k].add(text[1]);
  
    
   }
  });
 

b3.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
   
    
    b=b+1;
    text[1]=new JTextField(10);
    
    t.add(panel[b]); 
    panel[b].setLayout(new GridLayout(1,1,6,5));
    
    panel[b].setBorder(new TitledBorder("blend "));
   
    panel[b].add(text[1]);
  
    
   }
  });
b4.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
     
     if (m==-1) {}
     else
     {
         
    c = panel[m].getComponentCount();
     
    if (c ==1) {}
    else
    {
     
      
     Component component = panel[m].getComponent(c-1);
     
    panel[m].remove(component);
    c = panel[m].getComponentCount();
     
    panel[m].setLayout(new GridLayout(c,1,6,5));
     
    validate();
     
    }
     }
   }
  }); 

b5.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
     

     if (m==-1) {}
     else
     {
            
      if (c==14) {}
      else
      {
     c = panel[m].getComponentCount();
 
     
     text[c+1]=new JTextField(10);
     
     
     panel[m].add(text[c+1]);

     c = panel[m].getComponentCount();
     
     
     panel[m].setLayout(new GridLayout(c,1,6,5));

     validate();
      }
     }     
    }
   });



b6.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
    
    f=f+1;
    cl[f] = new ConnectionLines();
    
   add(cl[f]);
    
   validate();
   

    
   }
  });


}



  public void mousePressed(MouseEvent e) 
  {}
  public void mouseReleased(MouseEvent e) 
  {}
  public void mouseEntered(MouseEvent e) 
  {}
  public void mouseExited(MouseEvent e) 
  {}
  public void mouseClicked(MouseEvent e) 
  {
     

   String name = e.getComponent().getName();
   m = Integer.parseInt(name);

   x = e.getX();
   y = e.getY();
   Point point= e.getPoint();
  
System.out.println(name);
System.out.println("x is " + e.getX());
System.out.println("y is " + e.getY());
System.out.println(point);
System.out.println(x + " " + y);
   
   }



 
 public static void main(String args[])
   {
    Try8 frame = new Try8();

    frame.setTitle("let's try");
    frame.setSize (400, 400);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible (true);
    Graphics g = frame.getGraphics();

    g.setColor(Color.RED);
    g.drawLine(10,10,500,500);
   }
  
  public class ConnectionLines extends JPanel 
   {
    
    public ConnectionLines() 
    {
     
     addMouseListener(new MouseListener()
     {
      public void mouseClicked(MouseEvent e) 
      {
        if (z==2) 
        {
 	z=0;  
        }

        xvalues[a]=e.getX();
        yvalues[a]=e.getY();
	cnt[z]=1;
        
System.out.println(a);
System.out.println(xvalues[0]);
System.out.println(yvalues[0]);
System.out.println("");
System.out.println(xvalues[1]);
System.out.println(yvalues[1]);
System.out.println("");

            
	   repaint();
             
                   
      }
 public void mousePressed(MouseEvent e) 
  {}
  public void mouseReleased(MouseEvent e) 
  {}
  public void mouseEntered(MouseEvent e) 
  {}
  public void mouseExited(MouseEvent e) 
  {}
     });
    }
  
    protected void paintComponent( Graphics g) 
      {
	
       super.paintComponent(g);
       if((cnt[0] != -1) && (cnt[1] != -1))
       {
        g.drawLine(xvalues[a-1],yvalues[a-1],xvalues[a],yvalues[a]);
        cnt[0] = -1;
       }
       z=z+1;
       a=a+1;
      }
 
  }


 
}

OK, I put this quickly together

/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Apr-2009
 * Time: 15:55:39
 */
import javax.swing.SwingUtilities;

public class JFrameWithLines {

    public static void main(String[] args){

        SwingUtilities.invokeLater(new Runnable(){
            public void run(){
                TheJFrame myFrame = new TheJFrame();
                myFrame.runTheJFrame();
            }
        });

    }
}
/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Apr-2009
 * Time: 15:56:14
 */

import java.awt.*;

import javax.swing.*;

public class TheJFrame extends JFrame {

    public TheJFrame() {
        super("My JFrame with multiple JPanels of a line");
    }

    public void runTheJFrame() {
        Dimension d = new Dimension(500, 550);
        setSize(d);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        MainPanel mainPanel = new MainPanel();
        getContentPane().add(mainPanel);
        setResizable(false);
        setVisible(true);
    }

    public class MainPanel extends JPanel {
        public MainPanel() {
            super();
            setPreferredSize(new Dimension(490, 490));
            setLayout(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(0, 5, 0, 5);
            MyPanel mPanelOne = new MyPanel();
            mPanelOne.setLabel("Panel One");
            gbc.gridx = 0;
            gbc.gridy = 0;
            add(mPanelOne, gbc);
            MyPanel mPanelTwo = new MyPanel();
            mPanelTwo.setLabel("Panel 2");
            gbc.gridx = 0;
            gbc.gridy = 1;
            add(mPanelTwo, gbc);
            setVisible(true);
        }
    }
}
/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Apr-2009
 * Time: 17:02:31
 */
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;


public class MyPanel extends JPanel {

    private JLabel jlab;

    public MyPanel() {
        super();
        setPreferredSize(new Dimension(480, 250));
        setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.insets = new Insets(0, 5, 0, 5);
        jlab = new JLabel();
        Font curFont = jlab.getFont();
        jlab.setFont(new Font(curFont.getFontName(), Font.BOLD, 20));
        gbc.gridx = 0;
        gbc.gridy = 0;
        add(jlab, gbc);
        JPanelWithTextField jPanelJTF = new JPanelWithTextField();
        gbc.gridx = 0;
        gbc.gridy = 1;
        add(jPanelJTF, gbc);
        ThePanelWithLine linePanel = new ThePanelWithLine();
        gbc.gridx = 0;
        gbc.gridy = 2;
        add(linePanel, gbc);
    }

    public void setLabel(String str){
        jlab.setText(str);
    }
}
/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Apr-2009
 * Time: 16:21:42
 */
import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JTextField;

public class JPanelWithTextField extends JPanel{

    public JPanelWithTextField(){
        super();
        setPreferredSize(new Dimension(400, 40));
        JTextField jTField = new JTextField(10);
        add(jTField);
        setVisible(true);
    }
}
/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Apr-2009
 * Time: 15:56:28
 */

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.geom.Line2D;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JPanel;

public class ThePanelWithLine extends JPanel {

    public ThePanelWithLine() {
        super();
        setPreferredSize(new Dimension(400, 40));
    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        Line2D line = new Line2D.Double(5, 5, 350, 5);
        g2.setStroke(new BasicStroke(2.0f));
        g2.setColor(Color.BLACK);
        //draw shape of line
        g2.draw(line);
    }
}

If I spent more time on it I could pass to class that draw line on panel various parameters such as starting ending point, line thickness or line colour.
I hope you get the general idea now

OK, I put this quickly together

/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Apr-2009
 * Time: 15:55:39
 */
import javax.swing.SwingUtilities;

public class JFrameWithLines {

    public static void main(String[] args){

        SwingUtilities.invokeLater(new Runnable(){
            public void run(){
                TheJFrame myFrame = new TheJFrame();
                myFrame.runTheJFrame();
            }
        });

    }
}
/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Apr-2009
 * Time: 15:56:14
 */

import java.awt.*;

import javax.swing.*;

public class TheJFrame extends JFrame {

    public TheJFrame() {
        super("My JFrame with multiple JPanels of a line");
    }

    public void runTheJFrame() {
        Dimension d = new Dimension(500, 550);
        setSize(d);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        MainPanel mainPanel = new MainPanel();
        getContentPane().add(mainPanel);
        setResizable(false);
        setVisible(true);
    }

    public class MainPanel extends JPanel {
        public MainPanel() {
            super();
            setPreferredSize(new Dimension(490, 490));
            setLayout(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(0, 5, 0, 5);
            MyPanel mPanelOne = new MyPanel();
            mPanelOne.setLabel("Panel One");
            gbc.gridx = 0;
            gbc.gridy = 0;
            add(mPanelOne, gbc);
            MyPanel mPanelTwo = new MyPanel();
            mPanelTwo.setLabel("Panel 2");
            gbc.gridx = 0;
            gbc.gridy = 1;
            add(mPanelTwo, gbc);
            setVisible(true);
        }
    }
}
/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Apr-2009
 * Time: 17:02:31
 */
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;


public class MyPanel extends JPanel {

    private JLabel jlab;

    public MyPanel() {
        super();
        setPreferredSize(new Dimension(480, 250));
        setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.insets = new Insets(0, 5, 0, 5);
        jlab = new JLabel();
        Font curFont = jlab.getFont();
        jlab.setFont(new Font(curFont.getFontName(), Font.BOLD, 20));
        gbc.gridx = 0;
        gbc.gridy = 0;
        add(jlab, gbc);
        JPanelWithTextField jPanelJTF = new JPanelWithTextField();
        gbc.gridx = 0;
        gbc.gridy = 1;
        add(jPanelJTF, gbc);
        ThePanelWithLine linePanel = new ThePanelWithLine();
        gbc.gridx = 0;
        gbc.gridy = 2;
        add(linePanel, gbc);
    }

    public void setLabel(String str){
        jlab.setText(str);
    }
}
/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Apr-2009
 * Time: 16:21:42
 */
import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JTextField;

public class JPanelWithTextField extends JPanel{

    public JPanelWithTextField(){
        super();
        setPreferredSize(new Dimension(400, 40));
        JTextField jTField = new JTextField(10);
        add(jTField);
        setVisible(true);
    }
}
/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Apr-2009
 * Time: 15:56:28
 */

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.geom.Line2D;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JPanel;

public class ThePanelWithLine extends JPanel {

    public ThePanelWithLine() {
        super();
        setPreferredSize(new Dimension(400, 40));
    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        Line2D line = new Line2D.Double(5, 5, 350, 5);
        g2.setStroke(new BasicStroke(2.0f));
        g2.setColor(Color.BLACK);
        //draw shape of line
        g2.draw(line);
    }
}

If I spent more time on it I could pass to class that draw line on panel various parameters such as starting ending point, line thickness or line colour.
I hope you get the general idea now

hey hey
thanks for your help! Im new to (java) programming so to be honest I don't really understand everything you wrote. So i'm reading about runnable and threads etc but it's new to me !
so what I should basically do is change it and create the jframe runnable and then just write different classes to add the components right?
I don't really understand why though, because then you can do several things at the same time, in my case you can add jpanels of lines and jpanels with textfields or something? Ow and why do you use Graphics2D and not just Graphics?
And where should I then implement the mouseListener? In the end the program is supposed to draw lines between two textfields that are clicked. Do you think that is possible? And where should I add the mouseListener if I rewrite the program using all these classes?
Sorry for all these questions, as I said I'm new and I did do some research on the internet but it's so hard to follow....

Thanks again! I really appreciate your help!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.