1 5 package net.sf.panoptes.swing.dialogs; 6 7 import java.awt.BorderLayout ; 8 import java.awt.Frame ; 9 import java.awt.HeadlessException ; 10 11 import javax.swing.ImageIcon ; 12 import javax.swing.JDialog ; 13 import javax.swing.JFrame ; 14 import javax.swing.JPanel ; 15 import javax.swing.JSeparator ; 16 import javax.swing.UIManager ; 17 18 import com.jgoodies.forms.factories.Borders; 19 import net.sf.panoptes.swing.panels.BannerPanel; 20 21 27 public class BannerDialog extends JDialog { 28 29 public static int OK = 1; 30 public static int CANCEL = 2; 31 public static int YES = 3; 32 public static int NO = 4; 33 34 private JPanel contentPane; 35 private JPanel bottomPanel; 36 private BannerPanel bannerPanel; 37 38 private int result = -1; 39 40 46 public BannerDialog( 47 Frame owner, 48 String title, 49 String shortDescription, 50 String fullDescription, 51 String bannerIconName, 52 boolean modal, boolean resizable) 53 throws HeadlessException { 54 super(owner, title, modal); 55 setResizable(resizable); 56 57 contentPane = new JPanel (new BorderLayout ()); 58 setContentPane(contentPane); 59 bannerPanel = new BannerPanel(shortDescription, fullDescription, new ImageIcon (getClass().getClassLoader().getResource(bannerIconName))); 60 contentPane.add(bannerPanel, BorderLayout.NORTH); 61 62 BorderLayout bottomLayout = new BorderLayout (); 63 bottomPanel = new JPanel (bottomLayout); 64 bottomPanel.add(new JSeparator (), BorderLayout.NORTH); 65 66 contentPane.add(bottomPanel, BorderLayout.SOUTH); 67 } 68 69 public void setMainPanel(JPanel mainPanel) { 70 mainPanel.setBorder(Borders.DIALOG_BORDER); 71 contentPane.add(mainPanel, BorderLayout.CENTER); 72 } 73 74 75 public void setButtonPanel(JPanel buttonPanel) { 76 buttonPanel.setBorder(Borders.DIALOG_BORDER); 77 bottomPanel.add(buttonPanel, BorderLayout.CENTER); 78 } 79 80 public void setFeedBack(String text) { 81 bannerPanel.getDescriptionLabel().setText(text); 82 } 83 84 public void setResult(int result) { 85 this.result = result; 86 } 87 88 public int getResult() { 89 return result; 90 } 91 92 public void show() { 93 setLocationRelativeTo(getParent()); 94 super.show(); 95 } 96 97 public static void main(String [] args) { 98 try { 99 UIManager.setLookAndFeel("com.jgoodies.plaf.plastic.PlasticXPLookAndFeel"); 100 } catch (Exception e) { 101 e.printStackTrace(); 102 } 103 BannerDialog d = 104 new BannerDialog( 105 new JFrame (), 106 "Connect", 107 "Connect", 108 "Connect to an MBean Server", 109 "d:/sf/panoptes/panoptes/src/resources/icons/banners/new_wiz.gif", 110 true, false); 111 d.pack(); 112 d.show(); 113 System.exit(0); 114 } 115 } 116 | Popular Tags |