I am learning java swing. The code below is a catch block which handles an IOException and shows a error message.
catch(IOException e)
{
System.out.println("IOException");
JOptionPane.showMessageDialog(null,"File not found",null,
JOptionPane.ERROR_MESSAGE);
}
I was thinking of declaring and customizing a JOptionPane of my own inside the catch block like the code below:
JOptionPane jop=new JOptionPane();
jop.setLayout(new BorderLayout());
JLabel im=new JLabel("Java Technology Dive Log",
new ImageIcon("images/gwhite.gif"),JLabel.CENTER);
jop.add(im,BorderLayout.NORTH);
jop.setVisible(true);
But the problem is that I don't know how to make it appear on the screen as the showMessageDialogue method does. Please help.
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…