Explain the code to create a textfield using java [closed]

In CreateNewJTextField: this.getContentPane().setLayout(new FlowLayout()); This create a Pane and sets a default layout. Pane is like a piece of paper on which you draw. JTextField field3 = new JTextField(10); add(field3); This creates a text field and adds it to that pane. In createAndShowGUI, you are adding this pane to a JFrame(the frame with minimize, close … Read more

Java graphs not appearing

I have learned that extending JFrame and JPanel is bad But if you need to draw in the GUI, you often need to extend JPanel, and that’s exactly what you should do here. For example the code where you draw with a Graphics object should be inside of the JPanel’s protected void paintComponent(Graphics g) method. … Read more