1

Eclipse Window Builder ツールキットを使用してフルスクリーン デスクトップ アプリを設計しています。設計
中にこの奇妙な問題を発見しました
。GroupLayout を使用しており、そこにコンポーネントを配置する必要がありますが、配置されているコンポーネントの違いを見ることができるように、私が提供した画像。

ここに画像の説明を入力

IDE によって生成されたソースは次のとおりです。

package info.visual.gui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import java.awt.Color;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;

public class MDI {

    public JFrame frame;
    /**
     * @wbp.nonvisual location=487,159
     */
    private final JButton button = new JButton("New button");

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    MDI window = new MDI();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public MDI() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.getContentPane().setBackground(new Color(0, 0, 0));

        JButton btnButton = new JButton("button1");
        GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
        groupLayout.setHorizontalGroup(
            groupLayout.createParallelGroup(Alignment.LEADING)
                .addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
                    .addContainerGap(319, Short.MAX_VALUE)
                    .addComponent(btnButton)
                    .addGap(26))
        );
        groupLayout.setVerticalGroup(
            groupLayout.createParallelGroup(Alignment.LEADING)
                .addGroup(groupLayout.createSequentialGroup()
                    .addGap(113)
                    .addComponent(btnButton)
                    .addContainerGap(125, Short.MAX_VALUE))
        );
        frame.getContentPane().setLayout(groupLayout);
        frame.setExtendedState(6);
        frame.setResizable(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

これらのコード行を見てください

/**
     * @wbp.nonvisual location=487,159
     */
    private final JButton button = new JButton("New button");

それは私が興味を持っていることであり、最も重要なのはこれが問題です。フレームが設計時にあるため、コンテンツペインをフルサイズに拡張するために何をすべきかを誰でも明確にすることができます...ありがとう..

4

1 に答える 1

0

ContentPane ではなく、フレームのサイズを変更することで解決しました。
フレーム (ウィンドウ) の右下をフレームの中央に到達するまでドラッグ アンド ドロップするだけです (たとえば)。ContentPane は新しいサイズになり、コンポーネントが正しく表示されるはずです。

于 2014-08-07T11:25:20.200 に答える