4 * Created on 2007/07/22, 11:17
7 package org.jent.checksmtp;
9 import java.awt.Dimension;
10 import java.awt.Point;
11 import java.awt.Toolkit;
12 import java.util.List;
18 public class ToListUI extends javax.swing.JFrame {
19 private List toList = null;
20 private ResultNotify resultNotify = null;
22 /** Creates new form ToListUI */
27 public ToListUI(ResultNotify processer, List toList) {
28 this(); //TODO: test dould call...
30 this.resultNotify = processer;
33 jList1.setListData(toList.toArray());
35 jList1.setVisible(true);
37 this.setVisible(true);
38 toFront(); //from Tiger... setAlwaysOnTop(true);
40 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
41 //If exsist configuration file, iconise at start up.
42 if ( ApplicationProperties.isFileLoaded() ) {
43 int x = ApplicationProperties.getConfirmDialogPosX();
44 int y = ApplicationProperties.getConfirmDialogPosY();
45 int w = ApplicationProperties.getConfirmDialogPosW();
46 int h = ApplicationProperties.getConfirmDialogPosH();
47 if ( x > screenSize.width ) {
48 x = screenSize.width - w;
49 if ( x < 0 ) { x = 0; };
51 if ( y > screenSize.height ) {
52 y = screenSize.height - h;
53 if ( y < 0 ) { y = 0; };
55 this.setBounds(x, y, w, h);
57 //No Configuration file.
58 Dimension frameSize = ApplicationProperties.getConfirmDialogSize();
59 if (frameSize.height > screenSize.height) {
60 frameSize.height = screenSize.height;
62 if (frameSize.width > screenSize.width) {
63 frameSize.width = screenSize.width;
66 (screenSize.width - frameSize.width) / 2,
67 (screenSize.height - frameSize.height) / 2,
68 frameSize.width, frameSize.height );
74 /** This method is called from within the constructor to
75 * initialize the form.
76 * WARNING: Do NOT modify this code. The content of this method is
77 * always regenerated by the Form Editor.
79 // <editor-fold defaultstate="collapsed" desc=" Generated Code">//GEN-BEGIN:initComponents
80 private void initComponents() {
81 jPanel1 = new javax.swing.JPanel();
82 jScrollPane1 = new javax.swing.JScrollPane();
83 jList1 = new javax.swing.JList();
84 jButtonOK = new javax.swing.JButton();
85 jButtonCancel = new javax.swing.JButton();
87 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
88 setTitle("Confirm Distination Address");
89 addWindowListener(new java.awt.event.WindowAdapter() {
90 public void windowClosed(java.awt.event.WindowEvent evt) {
91 formWindowClosed(evt);
95 jList1.setModel(new javax.swing.AbstractListModel() {
96 String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
97 public int getSize() { return strings.length; }
98 public Object getElementAt(int i) { return strings[i]; }
100 jScrollPane1.setViewportView(jList1);
102 jButtonOK.setText("OK");
103 jButtonOK.addActionListener(new java.awt.event.ActionListener() {
104 public void actionPerformed(java.awt.event.ActionEvent evt) {
105 jButtonOKActionPerformed(evt);
109 jButtonCancel.setText("Cancel");
110 jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
111 public void actionPerformed(java.awt.event.ActionEvent evt) {
112 jButtonCancelActionPerformed(evt);
116 org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
117 jPanel1.setLayout(jPanel1Layout);
118 jPanel1Layout.setHorizontalGroup(
119 jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
120 .add(jPanel1Layout.createSequentialGroup()
121 .addContainerGap(200, Short.MAX_VALUE)
126 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
129 jPanel1Layout.linkSize(new java.awt.Component[] {jButtonCancel, jButtonOK}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
131 jPanel1Layout.setVerticalGroup(
132 jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
133 .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
134 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
135 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
136 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
138 .add(jButtonCancel)))
141 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
142 getContentPane().setLayout(layout);
143 layout.setHorizontalGroup(
144 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
145 .add(layout.createSequentialGroup()
147 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
150 layout.setVerticalGroup(
151 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
152 .add(layout.createSequentialGroup()
154 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
158 }// </editor-fold>//GEN-END:initComponents
160 private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
162 resultNotify.sayNG();
163 }//GEN-LAST:event_formWindowClosed
165 private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
166 resultNotify.sayNG();
168 }//GEN-LAST:event_jButtonCancelActionPerformed
170 private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
172 resultNotify.sayOK();
174 }//GEN-LAST:event_jButtonOKActionPerformed
176 private boolean restorePosition() {
177 Point locationPoint = getLocationOnScreen(); //TODO: IllegalComponentStateException
178 int x = locationPoint.x;
179 int y = locationPoint.y;
180 int h = this.getHeight();
181 int w = this.getWidth();
182 boolean modified = false;
184 if ( x != ApplicationProperties.getConfirmDialogPosX()
185 || y != ApplicationProperties.getConfirmDialogPosY()
186 || h != ApplicationProperties.getConfirmDialogPosH()
187 || w != ApplicationProperties.getConfirmDialogPosW()
190 ApplicationProperties.setConfirmDialogPosX(x);
191 ApplicationProperties.setConfirmDialogPosY(y);
192 ApplicationProperties.setConfirmDialogPosH(h);
193 ApplicationProperties.setConfirmDialogPosW(w);
194 if ( !ApplicationProperties.save() ) {
195 //TODO: save error dialog.
202 * @param args the command line arguments
204 * public static void main(String args[]) {
205 * java.awt.EventQueue.invokeLater(new Runnable() {
206 * public void run() {
207 * new ToListUI().setVisible(true);
213 // Variables declaration - do not modify//GEN-BEGIN:variables
214 private javax.swing.JButton jButtonCancel;
215 private javax.swing.JButton jButtonOK;
216 private javax.swing.JList jList1;
217 private javax.swing.JPanel jPanel1;
218 private javax.swing.JScrollPane jScrollPane1;
219 // End of variables declaration//GEN-END:variables