1

私はGUIこのようなものを持っている必要があります:

ブロック図

ここでは、すべての長方形がボタンである必要があります。どうすればこれを達成できますか?のようなツールを提案してくださいJFormDesigner

4

2 に答える 2

2

私はJGraphでたくさんの良い経験をしました!

ここで達成できることのドキュメントといくつかの例を参照してください

ボタンと同じように、図の各ノードをクリックして、イベントをリッスンして操作することができます。JButton実際、図のノードにsを入れることができると思いますが、間違っている可能性があります。

編集:通常のJavaSwingコードを使用したレイアウトは次のようになります

import java.awt.BorderLayout;
import java.awt.Container;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class LayoutTest {

    public static void main(String[] args) {

        JFrame window = new JFrame();
        Container container = window.getContentPane();
        container.setLayout(new BorderLayout());

        JPanel centerPanel = new JPanel();
        centerPanel.add(new JButton("Center"));
        container.add(centerPanel, BorderLayout.CENTER);

        JPanel topPanel = new JPanel();
        topPanel.add(new JButton("b1"));
        container.add(topPanel, BorderLayout.NORTH);

        JPanel rightPanel = new JPanel();
        rightPanel.add(new JButton("b3"));
        container.add(rightPanel, BorderLayout.EAST);

        JPanel bottomPanel = new JPanel();
        bottomPanel.setLayout(new BorderLayout());

        JPanel bottomNorthPanel = new JPanel();
        bottomNorthPanel.add(new JButton("b2"));
        bottomPanel.add(bottomNorthPanel, BorderLayout.NORTH);

        JPanel bottomSouthPanel = new JPanel();
        bottomSouthPanel.add(new JButton("b2-1"));
        bottomSouthPanel.add(new JButton("b2-2"));

        bottomPanel.add(bottomSouthPanel, BorderLayout.SOUTH);

        container.add(bottomPanel, BorderLayout.SOUTH);

        window.setSize(320, 240);
        window.setVisible(true);

    }
}
于 2012-04-30T05:59:06.950 に答える
0

Java Swing に関することを求めていると思います。drawLine() と drawRect() を使用できますが、コンポーネントのペイントを制御する必要があります。これをよく理解して、ニーズに合った基本的なクラスを作成すると、本当にうまくいくようになります。
詳細については、Swing: A Beginner's Guide の Schildt の例を参照してください。495ページ

お役に立てれば..

于 2012-04-30T06:22:21.807 に答える