-3

jframe をカスタマイズしたいのですが、そのフレームは joptionpane のように機能するはずです。これは親と相対的です。私はこのようにすることができます。可能であれば、誰か助けてください。

4

2 に答える 2

3

少し調査すれば、あなたの質問に対する答えは、あなたが思っているよりもアクセスしやすいものです。

車輪の再発明は無駄です。JDialogハッキングされた の代わりに を使用してJFrameください。

また、質問にもう少し力を入れることを検討してください。回答の質は、質問の質を反映しています。

于 2013-09-17T10:07:04.113 に答える
1

以下は、JFrame を使用したダイアログの例です。ダイアログを使用して JFrame をカスタマイズしようとすることは、非常に不必要である可能性があります。これは、使用できるさまざまなダイアログのほんの一部に過ぎないからです。

また、GCrec が参照しているように、Oracle にはより詳しい説明を提供できるチュートリアルがあります。

  public class SO {

public static void main(String[] args) {

    //Shows a GUI to allow typed input        
    String showInput = JOptionPane.showInputDialog(new JFrame(), "Enter some input:");
    //Shows a GUI displaying a message, in this case the typed input
    JOptionPane.showMessageDialog(new JFrame(), showInput);
    //A confirmation dialog for choosing yes or no
    JOptionPane.showConfirmDialog(new JFrame(), "Was that correct?");
    //Options for the below GUI where you have a range of options.  The int response 
    //varies depending on what you select. Then use something like an if statement to react to the input
    String[] options = {"Red", "Blue", "Green"};
     int response = JOptionPane.showOptionDialog( null, "Favorite Colour?", "Choice?", JOptionPane.YES_NO_OPTION    , JOptionPane.PLAIN_MESSAGE , null, options, "Wide Search");


    //The one you probably want, the JDialog which is basically a JFrame with a file selection dialog inside         
     FileDialog fc = new FileDialog(new JFrame(), "File Dialog");
    fc.setVisible(true);
    String selectedFile = fc.getFile();
     System.out.println("You have selected: " + selectedFile);
     File f = new File(selectedFile);
     JOptionPane.showMessageDialog(new JFrame(), f.getAbsolutePath());
}

お役に立てれば!幸運を

于 2013-09-17T11:20:09.590 に答える