1 56 package org.objectstyle.cayenne.modeler.util; 57 58 import java.awt.BorderLayout ; 59 import java.awt.Container ; 60 import java.awt.FlowLayout ; 61 62 import javax.swing.JButton ; 63 import javax.swing.JDialog ; 64 import javax.swing.JFrame ; 65 import javax.swing.JLabel ; 66 import javax.swing.JPanel ; 67 import javax.swing.JProgressBar ; 68 import javax.swing.SwingConstants ; 69 70 import org.scopemvc.view.awt.AWTUtilities; 71 72 import com.jgoodies.forms.builder.PanelBuilder; 73 import com.jgoodies.forms.layout.CellConstraints; 74 import com.jgoodies.forms.layout.FormLayout; 75 76 82 public class ProgressDialog extends JDialog { 83 84 protected JProgressBar progressBar; 85 protected JLabel statusLabel; 86 protected JButton cancelButton; 87 88 public ProgressDialog(JFrame parent, String title, String message) { 89 super(parent, title); 90 init(message); 91 } 92 93 private void init(String message) { 94 progressBar = new JProgressBar (); 95 statusLabel = new JLabel (message, SwingConstants.LEFT); 96 JLabel messageLabel = new JLabel (message, SwingConstants.LEFT); 97 cancelButton = new JButton ("Cancel"); 98 99 CellConstraints cc = new CellConstraints(); 101 FormLayout layout = new FormLayout("fill:max(250dlu;pref)", "p, 3dlu, p, 3dlu, p"); 102 PanelBuilder builder = new PanelBuilder(layout); 103 builder.setDefaultDialogBorder(); 104 105 builder.add(messageLabel, cc.xy(1, 1)); 106 builder.add(progressBar, cc.xy(1, 3)); 107 builder.add(statusLabel, cc.xy(1, 5)); 108 109 JPanel buttons = new JPanel (new FlowLayout (FlowLayout.RIGHT)); 110 buttons.add(cancelButton); 111 112 Container root = getContentPane(); 113 root.setLayout(new BorderLayout (5, 5)); 114 115 root.add(builder.getPanel(), BorderLayout.CENTER); 116 root.add(buttons, BorderLayout.SOUTH); 117 118 setResizable(false); 119 pack(); 120 AWTUtilities.centreOnWindow(getOwner(), this); 121 } 122 123 public JButton getCancelButton() { 124 return cancelButton; 125 } 126 127 public JLabel getStatusLabel() { 128 return statusLabel; 129 } 130 131 public JProgressBar getProgressBar() { 132 return progressBar; 133 } 134 } | Popular Tags |