Nie widać JTextArea po umieszczeniu w JScrollPane, czy wpływ może mieć na to JPanel?

0

Witam.

Problem taki jak w temacie... JTextArea nie wyświetla się w oknie po dodaniu do JScrollPane. Robię wszystko tak jak w podręczniku i nic. Czy to może być spowodowane tym że jest ono umieszczone w tym samym oknie po którym się rysuje?

final JTextArea textArea = new JTextArea();
		textArea.setBounds(1100, 38, -1052, 393);
		textArea.setBackground(Color.LIGHT_GRAY);
		textArea.setFont(new Font("Tahoma", Font.BOLD, 20));
	
		
		JScrollPane scrollPane = new JScrollPane(textArea);
		scrollPane.setBounds(1100, 38, -1052, 393);
		getContentPane().add(scrollPane);
1

A dlaczego ten ScrollPanel ma ujemną szerokość?

0

Co do getContentPane() to eclipse automatycznie mi to wszystko ustawia, nawet jak usunę... A co do szerokości to dziwne bo w designerze jest na połowę ekranu.

Tak problem był z tą ujemną wartością... ale nie była to szerokość tylko położenie na X. Nie sprawdziłem tego bo w designerze wszystko znajdowało się na miejscu, ale w kodzie mi ustawiało inne wartości...

0

Fragment dokumentacji:

public void setBounds(int x,
int y,
int width,
int height)

Moves and resizes this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height.

This method changes layout-related information, and therefore, invalidates the component hierarchy.

Parameters:
x - the new x-coordinate of this component
y - the new y-coordinate of this component
width - the new width of this component
height - the new height of this component

0

Tak wiem, właśnie sprawdzałem przed chwilą w dokumentacji żeby zobaczyć czy faktycznie argument oznacza położenie... ale nie zmienia to faktu że w designerze pokazywało że wszystko jest w porządku. A po zmianie wartości na wartość dodatnią nagle wszystko zniknęło i pojawiło się za prawym rogiem okna.

1 użytkowników online, w tym zalogowanych: 0, gości: 1