一番シンプルなやつ
JOptionPane.showMessageDialog(null, "メッセージだよ");
第一引数・・・ダイアログのFrame。nullの場合はデフォルトのFrameが使用される
第二引数・・・表示するメッセージ
いろいろ弄りたい場合は以下参考
import javax.swing.*; import java.awt.Color; import java.awt.BorderLayout; import java.awt.event.*; public class JOptionPaneTest2 extends JFrame implements ActionListener{ public static void main(String[] args){ JOptionPaneTest2 frame = new JOptionPaneTest2(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(10, 10, 300, 200); frame.setTitle("タイトル"); frame.setVisible(true); } JOptionPaneTest2(){ JButton button = new JButton("dialog"); button.addActionListener(this); JPanel p = new JPanel(); p.add(button); getContentPane().add(p, BorderLayout.CENTER); } public void actionPerformed(ActionEvent e){ JLabel label = new JLabel("Message"); label.setForeground(Color.RED); JOptionPane.showMessageDialog(this, label); } }