What I'm trying to do is place the GridBagLayout panel in the center of my BorderLayout and vertically align the GridBagLayout panel (and the text on it) to TOP (because it automatically places it in the middle, horizontally and vertically)).
So, what I tried (but in the end I got the text GridBagLayout back in the middle of the page, and not in the middle of x and the top of y):
import java.awt.*;
import java.applet.*;
import javax.swing.*;
import javax.imageio.*;
import javax.swing.BorderFactory;
import javax.swing.border.*;
import java.awt.event.*;
public class Test extends JApplet implements MouseListener, ActionListener {
public void init() {
this.setLayout(new BorderLayout());
JPanel gb = new JPanel(new GridBagLayout());
JLabel content = new JLabel("Some text");
setGBC(0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.NORTH);
gb.add(content, gbc);
this.add(gb, BorderLayout.CENTER);
}
}
, gridbagconstraints, , , , , . GridBagLayout ( , 100%, panel.setSize setPreferredSize), gridbagconstraints.anchor, .
- ?
,
,
Skyfe.
, :