001: /*
002: * Copyright (c) 2007, Sun Microsystems, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * * Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * * Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * * Neither the name of Sun Microsystems, Inc. nor the names of its contributors
015: * may be used to endorse or promote products derived from this software without
016: * specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
028: * THE POSSIBILITY OF SUCH DAMAGE.
029: */
030:
031: package examples;
032:
033: public class ContactEditor extends javax.swing.JFrame {
034:
035: /**
036: * Creates new form ContactEditor
037: */
038: public ContactEditor() {
039: initComponents();
040: }
041:
042: /** This method is called from within the constructor to
043: * initialize the form.
044: * WARNING: Do NOT modify this code. The content of this method is
045: * always regenerated by the Form Editor.
046: */
047: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
048: private void initComponents() {
049: buttonGroup1 = new javax.swing.ButtonGroup();
050: jPanel1 = new javax.swing.JPanel();
051: jLabel1 = new javax.swing.JLabel();
052: jLabel2 = new javax.swing.JLabel();
053: jTextField1 = new javax.swing.JTextField();
054: jTextField2 = new javax.swing.JTextField();
055: jLabel3 = new javax.swing.JLabel();
056: jTextField3 = new javax.swing.JTextField();
057: jLabel4 = new javax.swing.JLabel();
058: jTextField4 = new javax.swing.JTextField();
059: jLabel5 = new javax.swing.JLabel();
060: jComboBox1 = new javax.swing.JComboBox();
061: jPanel2 = new javax.swing.JPanel();
062: jLabel6 = new javax.swing.JLabel();
063: jTextField5 = new javax.swing.JTextField();
064: jScrollPane1 = new javax.swing.JScrollPane();
065: jList1 = new javax.swing.JList();
066: jButton1 = new javax.swing.JButton();
067: jButton2 = new javax.swing.JButton();
068: jButton3 = new javax.swing.JButton();
069: jButton4 = new javax.swing.JButton();
070: jLabel7 = new javax.swing.JLabel();
071: jRadioButton1 = new javax.swing.JRadioButton();
072: jRadioButton2 = new javax.swing.JRadioButton();
073: jRadioButton3 = new javax.swing.JRadioButton();
074: jButton5 = new javax.swing.JButton();
075: jButton6 = new javax.swing.JButton();
076:
077: setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
078: setTitle("E-mail Contacts");
079: jPanel1.setBorder(javax.swing.BorderFactory
080: .createTitledBorder(" Name "));
081: jLabel1.setText("First Name:");
082:
083: jLabel2.setText("Last Name:");
084:
085: jTextField1.setText("John");
086:
087: jTextField2.setText("Guy");
088:
089: jLabel3.setText("Title:");
090:
091: jTextField3.setText("Prof, DrSC");
092:
093: jLabel4.setText("Nickname:");
094:
095: jTextField4.setText("gui-master");
096:
097: jLabel5.setText("Display Format:");
098:
099: jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(
100: new String[] { "[Nickname] First_Name + Last_Name" }));
101:
102: org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(
103: jPanel1);
104: jPanel1.setLayout(jPanel1Layout);
105: jPanel1Layout
106: .setHorizontalGroup(jPanel1Layout
107: .createParallelGroup(
108: org.jdesktop.layout.GroupLayout.LEADING)
109: .add(
110: org.jdesktop.layout.GroupLayout.LEADING,
111: jPanel1Layout
112: .createSequentialGroup()
113: .addContainerGap()
114: .add(
115: jPanel1Layout
116: .createParallelGroup(
117: org.jdesktop.layout.GroupLayout.TRAILING)
118: .add(jLabel5)
119: .add(jLabel3)
120: .add(jLabel1))
121: .addPreferredGap(
122: org.jdesktop.layout.LayoutStyle.RELATED)
123: .add(
124: jPanel1Layout
125: .createParallelGroup(
126: org.jdesktop.layout.GroupLayout.LEADING)
127: .add(
128: org.jdesktop.layout.GroupLayout.LEADING,
129: jPanel1Layout
130: .createSequentialGroup()
131: .add(
132: jPanel1Layout
133: .createParallelGroup(
134: org.jdesktop.layout.GroupLayout.LEADING)
135: .add(
136: jTextField3,
137: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
138: 157,
139: Short.MAX_VALUE)
140: .add(
141: org.jdesktop.layout.GroupLayout.TRAILING,
142: jTextField1,
143: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
144: 157,
145: Short.MAX_VALUE))
146: .addPreferredGap(
147: org.jdesktop.layout.LayoutStyle.RELATED)
148: .add(
149: jPanel1Layout
150: .createParallelGroup(
151: org.jdesktop.layout.GroupLayout.TRAILING)
152: .add(
153: jLabel2)
154: .add(
155: jLabel4))
156: .addPreferredGap(
157: org.jdesktop.layout.LayoutStyle.RELATED)
158: .add(
159: jPanel1Layout
160: .createParallelGroup(
161: org.jdesktop.layout.GroupLayout.LEADING)
162: .add(
163: jTextField2,
164: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
165: 157,
166: Short.MAX_VALUE)
167: .add(
168: jTextField4,
169: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
170: 157,
171: Short.MAX_VALUE)))
172: .add(
173: jComboBox1,
174: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
175: 376,
176: Short.MAX_VALUE))
177: .addContainerGap()));
178: jPanel1Layout
179: .setVerticalGroup(jPanel1Layout
180: .createParallelGroup(
181: org.jdesktop.layout.GroupLayout.LEADING)
182: .add(
183: org.jdesktop.layout.GroupLayout.LEADING,
184: jPanel1Layout
185: .createSequentialGroup()
186: .add(
187: jPanel1Layout
188: .createParallelGroup(
189: org.jdesktop.layout.GroupLayout.BASELINE)
190: .add(jLabel1)
191: .add(
192: jTextField2,
193: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
194: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
195: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
196: .add(
197: jTextField1,
198: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
199: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
200: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
201: .add(jLabel2))
202: .addPreferredGap(
203: org.jdesktop.layout.LayoutStyle.RELATED)
204: .add(
205: jPanel1Layout
206: .createParallelGroup(
207: org.jdesktop.layout.GroupLayout.BASELINE)
208: .add(jLabel3)
209: .add(
210: jTextField4,
211: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
212: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
213: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
214: .add(jLabel4)
215: .add(
216: jTextField3,
217: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
218: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
219: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
220: .addPreferredGap(
221: org.jdesktop.layout.LayoutStyle.RELATED)
222: .add(
223: jPanel1Layout
224: .createParallelGroup(
225: org.jdesktop.layout.GroupLayout.BASELINE)
226: .add(jLabel5)
227: .add(
228: jComboBox1,
229: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
230: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
231: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
232: .addContainerGap(
233: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
234: Short.MAX_VALUE)));
235:
236: jPanel2.setBorder(javax.swing.BorderFactory
237: .createTitledBorder(" E-mail "));
238: jLabel6.setText("E-mail Address:");
239:
240: jList1.setModel(new javax.swing.AbstractListModel() {
241: String[] strings = { "john.guy@xxxxxx.yyy",
242: "gui@yyyyyy.xxx" };
243:
244: public int getSize() {
245: return strings.length;
246: }
247:
248: public Object getElementAt(int i) {
249: return strings[i];
250: }
251: });
252: jScrollPane1.setViewportView(jList1);
253:
254: jButton1.setText("Add");
255:
256: jButton2.setText("Edit");
257:
258: jButton3.setText("Remove");
259:
260: jButton4.setText("Default");
261:
262: jLabel7.setText("Mail Format:");
263:
264: buttonGroup1.add(jRadioButton1);
265: jRadioButton1.setSelected(true);
266: jRadioButton1.setText("HTML");
267: jRadioButton1.setBorder(javax.swing.BorderFactory
268: .createEmptyBorder(0, 0, 0, 0));
269: jRadioButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));
270:
271: buttonGroup1.add(jRadioButton2);
272: jRadioButton2.setText("Plain Text");
273: jRadioButton2.setBorder(javax.swing.BorderFactory
274: .createEmptyBorder(0, 0, 0, 0));
275: jRadioButton2.setMargin(new java.awt.Insets(0, 0, 0, 0));
276:
277: buttonGroup1.add(jRadioButton3);
278: jRadioButton3.setText("Custom");
279: jRadioButton3.setBorder(javax.swing.BorderFactory
280: .createEmptyBorder(0, 0, 0, 0));
281: jRadioButton3.setMargin(new java.awt.Insets(0, 0, 0, 0));
282:
283: org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(
284: jPanel2);
285: jPanel2.setLayout(jPanel2Layout);
286: jPanel2Layout
287: .setHorizontalGroup(jPanel2Layout
288: .createParallelGroup(
289: org.jdesktop.layout.GroupLayout.LEADING)
290: .add(
291: org.jdesktop.layout.GroupLayout.LEADING,
292: jPanel2Layout
293: .createSequentialGroup()
294: .addContainerGap()
295: .add(
296: jPanel2Layout
297: .createParallelGroup(
298: org.jdesktop.layout.GroupLayout.LEADING)
299: .add(
300: org.jdesktop.layout.GroupLayout.LEADING,
301: jPanel2Layout
302: .createSequentialGroup()
303: .add(
304: 12,
305: 12,
306: 12)
307: .add(
308: jRadioButton1)
309: .addPreferredGap(
310: org.jdesktop.layout.LayoutStyle.RELATED)
311: .add(
312: jRadioButton2)
313: .addPreferredGap(
314: org.jdesktop.layout.LayoutStyle.RELATED)
315: .add(
316: jRadioButton3))
317: .add(
318: org.jdesktop.layout.GroupLayout.LEADING,
319: jPanel2Layout
320: .createSequentialGroup()
321: .add(
322: jPanel2Layout
323: .createParallelGroup(
324: org.jdesktop.layout.GroupLayout.LEADING)
325: .add(
326: org.jdesktop.layout.GroupLayout.LEADING,
327: jPanel2Layout
328: .createSequentialGroup()
329: .add(
330: jLabel6)
331: .addPreferredGap(
332: org.jdesktop.layout.LayoutStyle.RELATED)
333: .add(
334: jTextField5,
335: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
336: 298,
337: Short.MAX_VALUE))
338: .add(
339: jScrollPane1,
340: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
341: 376,
342: Short.MAX_VALUE))
343: .addPreferredGap(
344: org.jdesktop.layout.LayoutStyle.RELATED)
345: .add(
346: jPanel2Layout
347: .createParallelGroup(
348: org.jdesktop.layout.GroupLayout.LEADING)
349: .add(
350: jButton2)
351: .add(
352: jButton1)
353: .add(
354: jButton3)
355: .add(
356: jButton4)))
357: .add(jLabel7))
358: .addContainerGap()));
359:
360: jPanel2Layout.linkSize(new java.awt.Component[] { jButton1,
361: jButton2, jButton3, jButton4 },
362: org.jdesktop.layout.GroupLayout.HORIZONTAL);
363:
364: jPanel2Layout
365: .setVerticalGroup(jPanel2Layout
366: .createParallelGroup(
367: org.jdesktop.layout.GroupLayout.LEADING)
368: .add(
369: org.jdesktop.layout.GroupLayout.LEADING,
370: jPanel2Layout
371: .createSequentialGroup()
372: .add(
373: jPanel2Layout
374: .createParallelGroup(
375: org.jdesktop.layout.GroupLayout.BASELINE)
376: .add(jLabel6)
377: .add(
378: jTextField5,
379: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
380: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
381: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
382: .add(jButton1))
383: .addPreferredGap(
384: org.jdesktop.layout.LayoutStyle.RELATED)
385: .add(
386: jPanel2Layout
387: .createParallelGroup(
388: org.jdesktop.layout.GroupLayout.LEADING)
389: .add(
390: org.jdesktop.layout.GroupLayout.LEADING,
391: jPanel2Layout
392: .createSequentialGroup()
393: .add(
394: jButton2)
395: .addPreferredGap(
396: org.jdesktop.layout.LayoutStyle.RELATED)
397: .add(
398: jButton3)
399: .addPreferredGap(
400: org.jdesktop.layout.LayoutStyle.RELATED)
401: .add(
402: jButton4))
403: .add(
404: jScrollPane1,
405: 0,
406: 81,
407: Short.MAX_VALUE))
408: .addPreferredGap(
409: org.jdesktop.layout.LayoutStyle.RELATED)
410: .add(jLabel7)
411: .addPreferredGap(
412: org.jdesktop.layout.LayoutStyle.RELATED)
413: .add(
414: jPanel2Layout
415: .createParallelGroup(
416: org.jdesktop.layout.GroupLayout.BASELINE)
417: .add(
418: jRadioButton1)
419: .add(
420: jRadioButton2)
421: .add(
422: jRadioButton3))
423: .addContainerGap()));
424:
425: jButton5.setText("Cancel");
426:
427: jButton6.setText("OK");
428:
429: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
430: getContentPane());
431: getContentPane().setLayout(layout);
432: layout
433: .setHorizontalGroup(layout
434: .createParallelGroup(
435: org.jdesktop.layout.GroupLayout.LEADING)
436: .add(
437: org.jdesktop.layout.GroupLayout.LEADING,
438: layout
439: .createSequentialGroup()
440: .addContainerGap()
441: .add(
442: layout
443: .createParallelGroup(
444: org.jdesktop.layout.GroupLayout.LEADING)
445: .add(
446: org.jdesktop.layout.GroupLayout.TRAILING,
447: layout
448: .createSequentialGroup()
449: .add(
450: jButton6)
451: .addPreferredGap(
452: org.jdesktop.layout.LayoutStyle.RELATED)
453: .add(
454: jButton5))
455: .add(
456: jPanel1,
457: 0,
458: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
459: Short.MAX_VALUE)
460: .add(
461: org.jdesktop.layout.GroupLayout.TRAILING,
462: jPanel2))
463: .addContainerGap()));
464:
465: layout.linkSize(
466: new java.awt.Component[] { jButton5, jButton6 },
467: org.jdesktop.layout.GroupLayout.HORIZONTAL);
468:
469: layout
470: .setVerticalGroup(layout
471: .createParallelGroup(
472: org.jdesktop.layout.GroupLayout.LEADING)
473: .add(
474: org.jdesktop.layout.GroupLayout.LEADING,
475: layout
476: .createSequentialGroup()
477: .addContainerGap()
478: .add(
479: jPanel1,
480: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
481: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
482: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
483: .addPreferredGap(
484: org.jdesktop.layout.LayoutStyle.RELATED)
485: .add(jPanel2)
486: .addPreferredGap(
487: org.jdesktop.layout.LayoutStyle.RELATED)
488: .add(
489: layout
490: .createParallelGroup(
491: org.jdesktop.layout.GroupLayout.BASELINE)
492: .add(jButton5)
493: .add(jButton6))
494: .addContainerGap()));
495: pack();
496: }// </editor-fold>//GEN-END:initComponents
497:
498: /**
499: * @param args the command line arguments
500: */
501: public static void main(String args[]) {
502: java.awt.EventQueue.invokeLater(new Runnable() {
503: public void run() {
504: new ContactEditor().setVisible(true);
505: }
506: });
507: }
508:
509: // Variables declaration - do not modify//GEN-BEGIN:variables
510: private javax.swing.ButtonGroup buttonGroup1;
511: private javax.swing.JButton jButton1;
512: private javax.swing.JButton jButton2;
513: private javax.swing.JButton jButton3;
514: private javax.swing.JButton jButton4;
515: private javax.swing.JButton jButton5;
516: private javax.swing.JButton jButton6;
517: private javax.swing.JComboBox jComboBox1;
518: private javax.swing.JLabel jLabel1;
519: private javax.swing.JLabel jLabel2;
520: private javax.swing.JLabel jLabel3;
521: private javax.swing.JLabel jLabel4;
522: private javax.swing.JLabel jLabel5;
523: private javax.swing.JLabel jLabel6;
524: private javax.swing.JLabel jLabel7;
525: private javax.swing.JList jList1;
526: private javax.swing.JPanel jPanel1;
527: private javax.swing.JPanel jPanel2;
528: private javax.swing.JRadioButton jRadioButton1;
529: private javax.swing.JRadioButton jRadioButton2;
530: private javax.swing.JRadioButton jRadioButton3;
531: private javax.swing.JScrollPane jScrollPane1;
532: private javax.swing.JTextField jTextField1;
533: private javax.swing.JTextField jTextField2;
534: private javax.swing.JTextField jTextField3;
535: private javax.swing.JTextField jTextField4;
536: private javax.swing.JTextField jTextField5;
537: // End of variables declaration//GEN-END:variables
538:
539: }
|