• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 741
  • Last Modified:

Java Applet - JTextField and JTextArea not appearing fully??

HI

I've written a Java JApplet. Everythings working fine except for the JTextField and the JTextArea. They're initalised and set in the init() method but don't appear properly in the applet.

The appear invisible until clicked on or highlighted - then they appear - even though I used the '.setVisible(true)' method on both. I initalise buttons and labels which appear fine.


code:

setBackground(Color.gray);

chatArea = new JTextArea(5,60);
JScrollPane scrollPane = new JScrollPane(chatArea);
chatArea.setEditable(false);
chatArea.setVisible(true);
chatArea.setLineWrap(true);
chatArea.setWrapStyleWord(true);
chatArea.setBackground(java.awt.Color.white);
scrollPane.setBounds(10,720,200,50);
scrollPane.setVisible(true);


message = new JTextField(60);
message.setEditable(true);
message.setVisible(true);
message.setBackground(java.awt.Color.white);
message.setBounds(285,720,100,20);
message.requestFocus();


0
gibbonss
Asked:
gibbonss
1 Solution
 
antonsigurCommented:
try calling updateUI() on the components
0
 
objectsCommented:
u do not need to call setVisible().
do u add them to your applet in your init() method?
if not, then you'll need to force your applet to relayout its children after u add them:

add(message);
revalidate();
repaint();
0
 
Mayank SAssociate Director - Product EngineeringCommented:
objects is right. Please add the chatArea and message to your Applet in your init () method.

Mayank.
0
 
sexperts_exchangeCommented:
Hey Stephen,

can I have these points??!!!

Great!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now