Hi, I need an applet which contains one panel. The panel needs to be 550x400 pixels, the JTextField needs to be under the panel dynamic size. I want it to be like this: [topPanel] [textPanel]
However I am trying this, and it seems like the panel is filling all the space. The code:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JApplet;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Client extends JApplet
{
@Override
public void init()
{
try {
java.awt.EventQueue.invokeAndWait(new Runnable()
{
public void run()
{
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void initComponents()
{
JPanel topPanel = new javax.swing.JPanel();
topPanel.setBackground(Color.red);
topPanel.setSize(550, 400);
topPanel.setPreferredSize(new Dimension(550, 400));
topPanel.setMinimumSize(new Dimension(550, 400));
topPanel.setMaximumSize(new Dimension(550, 400));
JTextField myTextBox = new JTextField(255);
getContentPane().add(topPanel, java.awt.BorderLayout.NORTH);
getContentPane().add(myTextBox, java.awt.BorderLayout.SOUTH);
}
// TODO overwrite start(), stop() and destroy() methods
}
Thanks!