2 years ago

#27120

test-img

Pulse

JScrollPane not showing in java

I have a textarea which will contain a lot of input lines, and i need a scroll. i don't know why isnt it showing, there are no errors.

  JFrame main_GUI = new JFrame(); //main frame
  JPanel body = new JPanel(null);
  main_GUI.setLayout(null);  
  main_GUI.setSize(600, 600); //size
  
  body.setBounds(150, 50, 400, 500);
  main_GUI.add(body);


  JTextArea contacts_field = new JTextArea(); //the textarea that will contain a lot of lines
  JScrollPane scroll = new JScrollPane(contacts_field);

  body.add(contacts_field);
  body.add(scroll);

  main_GUI.setResizable(false);
  main_GUI.setLocationRelativeTo(null);
  main_GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  main_GUI.setVisible(true);

java

swing

jscrollpane

0 Answers

Your Answer

Accepted video resources