次のようなGUIを表示するJFrameを作成したい:http://i.stack.imgur.com/2POFs.png (画像を埋め込むことは許可されていません)
空白のスペースは同じX次元とY次元であり、ボタンは同じX次元とY次元であり、JTextAreaはフレームの半分です。
public static JFrame frame = new JFrame ("Launcher " + version);
public static GridBagConstraints c = new GridBagConstraints();
public static JTextArea news = new JTextArea();
public static JButton launchGame = new JButton("Launch Game");
public static JButton settings = new JButton("Settings");
public static JButton exitGame = new JButton("Exit");
public static void main(String[] args)
{
news.setEditable(false);
news.setBounds(0, 0, (screenSize.width - 500) / 2, screenSize.height - 400);
news.append(" NEWS:\n");
news.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.gray, Color.black));
frame.setLayout(new GridBagLayout());
frame.setBounds(300, 200, screenSize.width - 500, screenSize.height - 400);
c.fill = GridBagConstraints.VERTICAL;
c.weighty = 0.5;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 3;
frame.add(news, c);
frame.setVisible(true);
c.fill = GridBagConstraints.EAST;
c.weightx = 0.5;
c.gridx = 1;
c.gridheight = 1;
frame.add(launchGame, c);
c.gridy = 1;
frame.add(settings, c);
c.gridy = 2;
frame.add(exitGame, c);
}