I work in jave, IntelliJ.
I create a Frame (Window) in which I place various objects such as: Panel, Label, Button and TextArea. The problem is just in the last (as I understood). No matter what size my window is (at least setSize (1000, 1000)) ;, in the minimized mode it does not show objects starting from TextArea and everything below. Minimized mode If you expand it completely (or simply resize the window by pulling a corner), then all of my elements magically appear ! [Expanded mode ] 2 I don’t understand what the problem is, and you won’t ask Google such a vague question. Thank you in advance!

PanelClass() { super("Name"); // setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(300 , 400); setVisible(true); setLayout(new FlowLayout(FlowLayout.CENTER)); JPanel Panel_with_img = new JPanel(); add(Panel_with_img); Panel_with_img.add(new JLabel("img")); JPanel Panel_with_list = new JPanel(new GridLayout(5, 1)); add(Panel_with_list); Panel_with_list.add(new JLabel("Висельница")); Panel_with_list.add(new JLabel("Слово: ")); JLabel Lable_slovo = new JLabel("_ _ _"); Panel_with_list.add(Lable_slovo); Panel_with_list.add(new JLabel("Использованы: ")); JPanel Panel_for_letter = new JPanel(new FlowLayout(FlowLayout.LEADING)); Panel_for_letter.add(new JLabel("Буква: ")); JTextArea Label_Enter = new JTextArea("___"); Panel_for_letter.add(Label_Enter); JButton Button_enter = new JButton("Ввод"); Panel_for_letter.add(Button_enter); Panel_with_list.add(Panel_for_letter); } 
  • The problem is clearly in the choice of layout managers. FlowLayout, for example, does not reduce components, but hides them abroad if they do not fit. GridLayout also behaves in its own way. It is advisable for you to describe the behavior that you want and present the code so that we can look at it and execute it, and then correct it for your needs if the problem is in several lines. - ezhov_da
  • do setSize and setVisible after creating and adding all the components, or call revalidate() to recalculate the size and position. - zRrr 2:51 pm

1 answer 1

Use the pack () method, it will automatically select the normal size for your window, in the main element of the JFrame (instead of manually setSize ()). In order to manually distribute the location of objects, use Layouts.