Hello!

I would like to ask on how to create a node using GUI (pseudo code will really help) . It seems that my code does not create a node. I used JLabels and ActionListener to retrieve the data from the JLabels. My plan is to input all the necessary data in a window (As much as possible, I do not want to use JOptionPane unless it is really necessary).

Thanks in advance.

please post your code using code tags.

public class Node extends JFrame
				  implements Serializable{
	
	//global variables
	public String dept;
	public String pos;
	Node next;
	
	JFileChooser fc;
	static private final String newline = "\n";
	
	JLabel d;
	JLabel p;
	
	JTextField de;
	JTextField po;
		
	Database d = new Database();
	
	Container node = getContentPane();
			
	public Node(){
		super("EneBio Employee Database System");
		this.setSize(650, 450);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		node.setLayout(null);
		node.setBackground(new Color(45, 38, 72));

		fc = new JFileChooser();
			
		//LABELS
		//department
		d = new JLabel("DEPARTMENT: ");
		d.setLocation(220, 70);
		d.setSize(150, 30);
		node.add(d);
		
		//position
		p = new JLabel("POSITION: ");
		p.setSize(150, 30);
		node.add(p);
		
		//TEXTFIELDS
		//department
		de = new JTextField();
		de.setLocation(350, 70);
		de.setSize(250, 30);
		de.addActionListener(new TextFieldHandler());
		node.add(de);
		
		//position
		po = new JTextField();
		po.setLocation(350, 105);
		po.setSize(250, 30);
		po.addActionListener(new TextFieldHandler());
		node.add(po);
		
		d.insert(n);
	}//END OF CONSTRUCTOR
	
	
	    }
	
	private class TextFieldHandler implements ActionListener{
			
			public void actionPerformed(ActionEvent e) {
				if(e.getSource() == de){
					dept = e.getActionCommand();
				}else if(e.getSource() == po){
					pos = e.getActionCommand();
									
				}
				
			}
			
		
	}
	}
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.