I am adding an icon to a JOptionPane which also has a JPanel added. When the default cup of coffee icon is there, the JPanel is fully visible. Replacing that with my own icon pushes the JPanel over to the right so far some fields are not visible. I have tried scaling the icon but whether I scale it by 1/2, 1/3, 1/5, or 1/7, though the image itself changes in size, the amount of room the JOptionPane allocates for it remains uneffected pushing my poor JPanel out into the cold. Before I give up and write a custom dialog, I am curious: Am I overlooking some setting to have my JPanel begin where the width of my icon ends?
public void displayDialog(){
Image img = icon.getImage();
BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.createGraphics();
g.drawImage(img, 0, 0, img.getWidth(null)/7, img.getHeight(null)/7, null);
ImageIcon newIcon = new ImageIcon(bi);
Object[] options = {"Cancel", "Done"};// Cancel returns 0; Done returns 1
int n = JOptionPane.showOptionDialog(null, mainPanel,"New Certification Information",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if(n == 1){
//done option: expand later
}
}
BTW: Don't recall asking a question here before and don't know when I will again so, while I'm here....I use this site quite often. You all have been a great help to me and I am very grateful.