Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/fetish/toolkit/URLDialog.java


1   /*
2    * URLDialog.java
3    *
4    * Created on July 9, 2001, 3:32 PM
5    */
6   
7   package com.fetish.toolkit;
8   
9   import java.awt.*;
10  
11  /**
12   * Dialog for getting an URL from the user.
13   * @author  bnt
14   */
15  public class URLDialog extends javax.swing.JDialog {
16      
17      private boolean accepted = false;
18      private String url = "";
19  
20      /** Creates new form URLDialog */
21      public URLDialog(java.awt.Frame parent,boolean modal) {
22          super(parent, modal);
23          initComponents();
24          this.requestFocus();
25          Point location = parent.getLocation();
26          this.setLocation( location );
27          urlTextField.requestFocus();
28      }
29  
30      /** This method is called from within the constructor to
31       * initialize the form.
32       * WARNING: Do NOT modify this code. The content of this method is
33       * always regenerated by the Form Editor.
34       */
35      private void initComponents() {//GEN-BEGIN:initComponents
36          urlTextField = new javax.swing.JTextField();
37          jButton1 = new javax.swing.JButton();
38          jButton2 = new javax.swing.JButton();
39          jLabel1 = new javax.swing.JLabel();
40          getContentPane().setLayout(new java.awt.GridBagLayout());
41          java.awt.GridBagConstraints gridBagConstraints1;
42          addWindowListener(new java.awt.event.WindowAdapter() {
43              public void windowClosing(java.awt.event.WindowEvent evt) {
44                  closeDialog(evt);
45              }
46          }
47          );
48          
49          urlTextField.setToolTipText("New neighbor URL");
50          urlTextField.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
51          
52          gridBagConstraints1 = new java.awt.GridBagConstraints();
53          gridBagConstraints1.gridx = 0;
54          gridBagConstraints1.gridy = 1;
55          gridBagConstraints1.gridwidth = 2;
56          gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
57          gridBagConstraints1.weightx = 1.0;
58          gridBagConstraints1.weighty = 1.0;
59          getContentPane().add(urlTextField, gridBagConstraints1);
60          
61          
62          jButton1.setText("Accept");
63          jButton1.addActionListener(new java.awt.event.ActionListener() {
64              public void actionPerformed(java.awt.event.ActionEvent evt) {
65                  jButton1ActionPerformed(evt);
66              }
67          }
68          );
69          
70          gridBagConstraints1 = new java.awt.GridBagConstraints();
71          gridBagConstraints1.gridx = 0;
72          gridBagConstraints1.gridy = 2;
73          gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTH;
74          gridBagConstraints1.weightx = 0.5;
75          gridBagConstraints1.weighty = 1.0;
76          getContentPane().add(jButton1, gridBagConstraints1);
77          
78          
79          jButton2.setText("Cancel");
80          jButton2.addActionListener(new java.awt.event.ActionListener() {
81              public void actionPerformed(java.awt.event.ActionEvent evt) {
82                  jButton2ActionPerformed(evt);
83              }
84          }
85          );
86          
87          gridBagConstraints1 = new java.awt.GridBagConstraints();
88          gridBagConstraints1.gridx = 1;
89          gridBagConstraints1.gridy = 2;
90          gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTH;
91          gridBagConstraints1.weightx = 0.5;
92          gridBagConstraints1.weighty = 1.0;
93          getContentPane().add(jButton2, gridBagConstraints1);
94          
95          
96          jLabel1.setText("Enter new neighbor URL");
97          jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
98          
99          gridBagConstraints1 = new java.awt.GridBagConstraints();
100         gridBagConstraints1.gridwidth = 2;
101         gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
102         gridBagConstraints1.anchor = java.awt.GridBagConstraints.SOUTH;
103         gridBagConstraints1.weightx = 1.0;
104         getContentPane().add(jLabel1, gridBagConstraints1);
105         
106         pack();
107     }//GEN-END:initComponents
108 
109     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
110         // Add your handling code here:
111         this.accepted = false;
112         this.url = null;
113         this.setVisible(false);
114     }//GEN-LAST:event_jButton2ActionPerformed
115 
116     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
117         // Add your handling code here:
118         this.accepted = true;
119         this.url = this.urlTextField.getText();
120         this.setVisible( false );
121     }//GEN-LAST:event_jButton1ActionPerformed
122 
123     /** Closes the dialog */
124     private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
125         setVisible(false);
126         dispose();
127     }//GEN-LAST:event_closeDialog
128 
129     // Variables declaration - do not modify//GEN-BEGIN:variables
130     private javax.swing.JTextField urlTextField;
131     private javax.swing.JButton jButton1;
132     private javax.swing.JButton jButton2;
133     private javax.swing.JLabel jLabel1;
134     // End of variables declaration//GEN-END:variables
135 
136     public String getURL() {
137         return url;
138     }
139     
140     public boolean isAccepted() {
141         return accepted;
142     }
143     
144 }