Circuit Negma

C++, C, VB.NET, PCB, Electronics, Circuit Design

File Grabber – Update ver.1.1

Posted by Circuit Negma on March 3, 2006


The project is not yet completed

G:\Documents and Settings\nemo\My Documents\Programming\Java\url\src\url\urlGUI.java

  1 /*
  2  * urlGUI.java
  3  *
  4  * Created on March 1, 2006, 11:27 AM
  5  */
  6 
  7 package url;
  8 
  9 import java.net.*;
 10 import java.io.*;
 11 import java.awt.*;
 12 
 13 /**
 14  *
 15  * @author  nemo
 16  */
 17 public class urlGUI extends javax.swing.JFrame {
 18     
 19     // <editor-fold defaultstate="collapsed" desc=" Variable declaration">
 20     
 21     private String UrlAdrstr,UrlAdrver;
 22     private URL Urladr;
 23     private URLConnection connection;
 24     private String FileNamestr;
 25     protected static String FileNamestr1;
 26     protected static String FileNamestr2;
 27     protected static boolean FileNameflag;
 28     private int Startnum, Endnum;
 29     
 30     // </editor-fold>
 31    
 32     // <editor-fold defaultstate="collapsed" desc=" Creates new form urlGUI">
 33     /** Creates new form urlGUI */
 34     public urlGUI() {
 35         initComponents();
 36     } //</editor-fold>
 37     
 38     /** This method is called from within the constructor to
 39      * initialize the form.
 40      * WARNING: Do NOT modify this code. The content of this method is
 41      * always regenerated by the Form Editor.
 42      */
 43     
 44     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
 45     private void initComponents() {
 46         jPanel1 = new javax.swing.JPanel();
 47         jLabel1 = new javax.swing.JLabel();
 48         jTextField1 = new javax.swing.JTextField();
 49         jLabel2 = new javax.swing.JLabel();
 50         jTextField2 = new javax.swing.JTextField();
 51         jLabel3 = new javax.swing.JLabel();
 52         jTextField3 = new javax.swing.JTextField();
 53         jLabel4 = new javax.swing.JLabel();
 54         jTextField4 = new javax.swing.JTextField();
 55         jButton4 = new javax.swing.JButton();
 56         jPanel2 = new javax.swing.JPanel();
 57         jPanel3 = new javax.swing.JPanel();
 58         jScrollPane1 = new javax.swing.JScrollPane();
 59         jList1 = new javax.swing.JList();
 60         jPanel4 = new javax.swing.JPanel();
 61         jScrollPane2 = new javax.swing.JScrollPane();
 62         jList2 = new javax.swing.JList();
 63         jPanel5 = new javax.swing.JPanel();
 64         jScrollPane3 = new javax.swing.JScrollPane();
 65         jTextArea1 = new javax.swing.JTextArea();
 66         jPanel6 = new javax.swing.JPanel();
 67         jButton1 = new javax.swing.JButton();
 68         jButton2 = new javax.swing.JButton();
 69         jButton3 = new javax.swing.JButton();
 70         jPanel7 = new javax.swing.JPanel();
 71 
 72         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
 73         jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12)));
 74         jLabel1.setText("Url Address: ");
 75         jLabel1.setToolTipText("The Destination Address of Gallery");
 76 
 77         jTextField1.setToolTipText("The Destination Address with Filename not included");
 78 
 79         jLabel2.setText("File Name: ");
 80         jLabel2.setToolTipText("File Name with File Extension is not included");
 81 
 82         jTextField2.setToolTipText("Please Enter File Name only, no Extension");
 83 
 84         jLabel3.setText("Start #: ");
 85 
 86         jLabel4.setText("End #: ");
 87 
 88         jButton4.setText("Advanced");
 89         jButton4.setToolTipText("File Name Advanced Options");
 90         jButton4.addActionListener(new java.awt.event.ActionListener() {
 91             public void actionPerformed(java.awt.event.ActionEvent evt) {
 92                 jButton4ActionPerformed(evt);
 93             }
 94         });
 95 
 96         org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
 97         jPanel1.setLayout(jPanel1Layout);
 98         jPanel1Layout.setHorizontalGroup(
 99             jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
100             .add(jPanel1Layout.createSequentialGroup()
101                 .addContainerGap()
102                 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
103                     .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3)
104                     .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel2)
105                     .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel1))
106                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
107                 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
108                     .add(jPanel1Layout.createSequentialGroup()
109                         .add(jTextField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
110                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
111                         .add(jButton4)
112                         .addContainerGap())
113                     .add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
114                     .add(jPanel1Layout.createSequentialGroup()
115                         .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 95, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
116                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 105, Short.MAX_VALUE)
117                         .add(jLabel4)
118                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
119                         .add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 111, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
120                         .addContainerGap())))
121         );
122 
123         jPanel1Layout.linkSize(new java.awt.Component[] {jTextField3, jTextField4}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
124 
125         jPanel1Layout.setVerticalGroup(
126             jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
127             .add(jPanel1Layout.createSequentialGroup()
128                 .addContainerGap()
129                 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
130                     .add(jLabel1)
131                     .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
132                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
133                 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
134                     .add(jLabel2)
135                     .add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
136                     .add(jButton4))
137                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
138                 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
139                     .add(jLabel3)
140                     .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
141                     .add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
142                     .add(jLabel4))
143                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
144         );
145 
146         jPanel1Layout.linkSize(new java.awt.Component[] {jTextField3, jTextField4}, org.jdesktop.layout.GroupLayout.VERTICAL);
147 
148         jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Tags", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12)));
149         jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "File Ext.", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12)));
150         jList1.setModel(new javax.swing.AbstractListModel() {
151             String[] strings = { "jpg", "JPG", "bmp", "BMP", "gif", "GIF", "Custom" };
152             public int getSize() { return strings.length; }
153             public Object getElementAt(int i) { return strings[i]; }
154         });
155         jList1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
156         jScrollPane1.setViewportView(jList1);
157 
158         org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
159         jPanel3.setLayout(jPanel3Layout);
160         jPanel3Layout.setHorizontalGroup(
161             jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
162             .add(jPanel3Layout.createSequentialGroup()
163                 .addContainerGap()
164                 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
165                 .addContainerGap())
166         );
167         jPanel3Layout.setVerticalGroup(
168             jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
169             .add(jPanel3Layout.createSequentialGroup()
170                 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 97, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
171                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
172         );
173 
174         jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Tags", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12)));
175         jList2.setModel(new javax.swing.AbstractListModel() {
176             String[] strings = { "<img> ... </img>", "[img] ... [/img]", "[IMG] ... [/IMG]", "Custom" };
177             public int getSize() { return strings.length; }
178             public Object getElementAt(int i) { return strings[i]; }
179         });
180         jScrollPane2.setViewportView(jList2);
181 
182         org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
183         jPanel4.setLayout(jPanel4Layout);
184         jPanel4Layout.setHorizontalGroup(
185             jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
186             .add(jPanel4Layout.createSequentialGroup()
187                 .addContainerGap()
188                 .add(jScrollPane2)
189                 .addContainerGap())
190         );
191         jPanel4Layout.setVerticalGroup(
192             jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
193             .add(jPanel4Layout.createSequentialGroup()
194                 .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
195                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
196         );
197 
198         org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
199         jPanel2.setLayout(jPanel2Layout);
200         jPanel2Layout.setHorizontalGroup(
201             jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
202             .add(jPanel2Layout.createSequentialGroup()
203                 .addContainerGap()
204                 .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
205                     .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
206                     .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
207                 .addContainerGap())
208         );
209         jPanel2Layout.setVerticalGroup(
210             jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
211             .add(jPanel2Layout.createSequentialGroup()
212                 .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
213                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
214                 .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
215                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
216         );
217 
218         jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Output", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12)));
219         jTextArea1.setColumns(20);
220         jTextArea1.setRows(5);
221         jTextArea1.setToolTipText("Output Results");
222         jScrollPane3.setViewportView(jTextArea1);
223 
224         org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
225         jPanel5.setLayout(jPanel5Layout);
226         jPanel5Layout.setHorizontalGroup(
227             jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
228             .add(jPanel5Layout.createSequentialGroup()
229                 .addContainerGap()
230                 .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)
231                 .addContainerGap())
232         );
233         jPanel5Layout.setVerticalGroup(
234             jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
235             .add(jPanel5Layout.createSequentialGroup()
236                 .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
237                 .addContainerGap())
238         );
239 
240         jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Navigation", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12)));
241         jButton1.setText("Run");
242         jButton1.addActionListener(new java.awt.event.ActionListener() {
243             public void actionPerformed(java.awt.event.ActionEvent evt) {
244                 jButton1ActionPerformed(evt);
245             }
246         });
247 
248         jButton2.setText("Clear");
249         jButton2.addActionListener(new java.awt.event.ActionListener() {
250             public void actionPerformed(java.awt.event.ActionEvent evt) {
251                 jButton2ActionPerformed(evt);
252             }
253         });
254 
255         jButton3.setText("Stop");
256 
257         org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
258         jPanel6.setLayout(jPanel6Layout);
259         jPanel6Layout.setHorizontalGroup(
260             jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
261             .add(jPanel6Layout.createSequentialGroup()
262                 .addContainerGap(319, Short.MAX_VALUE)
263                 .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
264                     .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel6Layout.createSequentialGroup()
265                         .add(jButton1)
266                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
267                         .add(jButton2)
268                         .addContainerGap())
269                     .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel6Layout.createSequentialGroup()
270                         .add(jButton3)
271                         .add(34, 34, 34))))
272         );
273 
274         jPanel6Layout.linkSize(new java.awt.Component[] {jButton1, jButton2}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
275 
276         jPanel6Layout.setVerticalGroup(
277             jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
278             .add(jPanel6Layout.createSequentialGroup()
279                 .addContainerGap()
280                 .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
281                     .add(jButton1)
282                     .add(jButton2))
283                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
284                 .add(jButton3)
285                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
286         );
287 
288         jPanel6Layout.linkSize(new java.awt.Component[] {jButton1, jButton2}, org.jdesktop.layout.GroupLayout.VERTICAL);
289 
290         jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Thumb Strip", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12)));
291         org.jdesktop.layout.GroupLayout jPanel7Layout = new org.jdesktop.layout.GroupLayout(jPanel7);
292         jPanel7.setLayout(jPanel7Layout);
293         jPanel7Layout.setHorizontalGroup(
294             jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
295             .add(0, 100, Short.MAX_VALUE)
296         );
297         jPanel7Layout.setVerticalGroup(
298             jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
299             .add(0, 503, Short.MAX_VALUE)
300         );
301 
302         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
303         getContentPane().setLayout(layout);
304         layout.setHorizontalGroup(
305             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
306             .add(layout.createSequentialGroup()
307                 .addContainerGap()
308                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
309                     .add(jPanel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
310                     .add(layout.createSequentialGroup()
311                         .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
312                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
313                         .add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
314                     .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
315                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
316                 .add(jPanel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
317                 .addContainerGap())
318         );
319         layout.setVerticalGroup(
320             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
321             .add(layout.createSequentialGroup()
322                 .addContainerGap()
323                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
324                     .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
325                     .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
326                         .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
327                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
328                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
329                             .add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
330                             .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
331                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
332                         .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
333                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
334         );
335         pack();
336     }// </editor-fold>
337 
338     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
339 
340         // <editor-fold defaultstate="collapsed" desc=" Obtain URL Address and verify">
341             this.UrlAdrstr = this.jTextField1.getText().toLowerCase();
342             
343             if (this.UrlAdrstr.equals(""))
344             {
345                     this.jTextField1.setText("Please Enter a Valid internet Address");
346                     this.jTextField1.setBackground(Color.yellow);
347                     return;
348             }
349             
350             if (!UrlAdrstr.contains("http://"))
351                     this.UrlAdrstr = "http://" + UrlAdrstr;
352             
353            
354             
355             try {
356                 this.Urladr = new URL(this.UrlAdrstr);
357                 this.connection = this.Urladr.openConnection();    
358                     if (this.connection.getContentType() == null)
359                     {
360                         this.jTextField1.setText("Please Enter a Valid internet Address");
361                         this.jTextField1.setBackground(Color.yellow);
362                     }
363             }
364             catch (IOException e)
365             {
366                 System.out.println ("Error getting page " + e);
367             }
368         // </editor-fold>
369              
370         // <editor-fold defaultstate="collapsed" desc=" Obtain File Name and Verify ">
371             if (this.FileNameflag)
372             {
373                 this.FileNamestr = "";
374                 this.jTextField2.setText(this.FileNamestr1 + "xxx" + this.FileNamestr2);
375             }
376             else
377                 {
378                     this.FileNamestr = this.jTextField2.getText();
379                     this.FileNamestr1 = "";
380                     this.FileNamestr2 = "";
381                 }
382             
383         // </editor-fold>
384             
385         // <editor-fold defaultstate="collapsed" desc=" Obtain File Numbers and Verify ">
386             this.Startnum = GetIntegerValid(this.jTextField3.getText(), this.jTextField3);
387             this.Endnum = GetIntegerValid(this.jTextField4.getText(), this.jTextField4);
388             if(this.Startnum == 0)
389                 return;
390             else if (this.Endnum == 0)
391                 return;
392             
393                 System.out.println(this.Startnum);
394                 System.out.println(this.Endnum);
395         // </editor-fold>
396     }                                        
397 
398     // advanced button action
399     private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
400 // TODO add your handling code here:
401         new FileAdvancedGUI().setVisible(true);
402     }                                        
403 
404     // clear button action
405     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
406 // TODO add your handling code here:
407         this.FileNameflag = false;
408         this.jTextField1.setText("");
409         this.jTextField1.setBackground(Color.WHITE);
410         this.jTextField2.setText("");
411         this.jTextField3.setText("");
412         this.jTextField4.setText("");
413         this.jTextArea1.setText("");        
414         this.jList1.clearSelection();
415         this.jList2.clearSelection();
416     }                                        
417     
418     /**
419      * @param args the command line arguments
420      */
421     public static void main(String args[]) {
422         java.awt.EventQueue.invokeLater(new Runnable() {
423             public void run() {
424                 new urlGUI().setVisible(true);
425             }
426         });
427     }
428     
429     private int GetIntegerValid(String s, javax.swing.JTextField textfield)
430     {
431         int i = 0;
432         try{
433             i = new Integer(s).intValue();
434         }
435         catch(NumberFormatException e)
436         {
437             System.out.println(e);
438             textfield.setBackground(Color.YELLOW);
439             textfield.setText("Please Enter a Valid Number");
440         }
441         return i;
442     }
443     
444     // <editor-fold defaultstate="collapsed" desc="Variables Desclaration">
445     // Variables declaration - do not modify
446     private javax.swing.JButton jButton1;
447     private javax.swing.JButton jButton2;
448     private javax.swing.JButton jButton3;
449     private javax.swing.JButton jButton4;
450     private javax.swing.JLabel jLabel1;
451     private javax.swing.JLabel jLabel2;
452     private javax.swing.JLabel jLabel3;
453     private javax.swing.JLabel jLabel4;
454     private javax.swing.JList jList1;
455     private javax.swing.JList jList2;
456     private javax.swing.JPanel jPanel1;
457     private javax.swing.JPanel jPanel2;
458     private javax.swing.JPanel jPanel3;
459     private javax.swing.JPanel jPanel4;
460     private javax.swing.JPanel jPanel5;
461     private javax.swing.JPanel jPanel6;
462     private javax.swing.JPanel jPanel7;
463     private javax.swing.JScrollPane jScrollPane1;
464     private javax.swing.JScrollPane jScrollPane2;
465     private javax.swing.JScrollPane jScrollPane3;
466     private javax.swing.JTextArea jTextArea1;
467     private javax.swing.JTextField jTextField1;
468     private javax.swing.JTextField jTextField2;
469     private javax.swing.JTextField jTextField3;
470     private javax.swing.JTextField jTextField4;
471     // End of variables declaration
472     // </editor-fold>
473 }
474 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: