0

私はスイングから質問があります。2 つのフォームがあります。最初のフォームは MDI 用で、2 番目のフォームはログイン用です。ユーザーがパスワードとユーザー名を正しく入力すると、ユーザーは MDI のフォームにログインできるようになります。の MDI フォームの使用 jform と のログイン フォームの使用、これにログインjinternalframeを定義して追加しますが、 (MDI フォーム) でJDesktopPaneボタンを使用したいのですが、ボタンを に追加すると、追加できますが、ボタンの場所を設定できません。ボタンとボタンの位置を設定する方法を教えてください。jframeJDesktopPanejinternalframe

これは私のコードです:

     Login frame = new Login();
    frame.setVisible(true); 
    desktop=new JDesktopPane();
    desktop.add(frame,BorderLayout.CENTER);
    setContentPane(desktop);
    frame.setSelected(true);  
    frame.setLocation(500, 200);

    FlowLayout flo = new FlowLayout();
    desktop.setLayout(flo);
    JButton buttonSaveCustumer = new JButton("Create Customer");
    buttonSaveCustumer.setLocation(70, 80);
    this.add(buttonSaveCustumer);

よろしくお願いします

4

1 に答える 1

0

以下のメソッドを参照してください。//以下のメソッドを使用する前に、レイアウト プロパティを null に設定することを忘れないでください。

public void setBounds(int x, int y, int width, int height)

このコンポーネントを移動およびサイズ変更します。左上隅の新しい位置は x と y で指定され、新しいサイズは幅と高さで指定されます。このメソッドは、レイアウト関連の情報を変更するため、コンポーネント階層を無効にします。

Parameters:
x - the new x-coordinate of this component
y - the new y-coordinate of this component
width - the new width of this component
height - the new height of this component
于 2014-03-25T17:05:16.180 に答える