-
A prog i wrote and i cant fix
if u can fix this prog please email me at
planetvegita@dbzmail.com
heres the prog
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
class Browser extends JFrame
{
//declare all HCI elements
private JLabel locLabel, responseLabel, statusLabel, typeLabel, sizeLabel,
modifiedLabel;
private JTextField locDisplay, response, status, contentType, size, modified;
private JButton b;
private JScrollPane displayHolder;
private JTextArea display;
private ActionListener l;
public Browser()
{
Container c = getContentPane();
this.setTitle("Http Text Browser Made With Java by CJW");
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
JPanel pa = new JPanel();
pa.setBackground(Color.lightGray);
responseLabel = new JLabel("Pinged Server Response");
response = new JTextField(20);
response.setEditable(false);
statusLabel = new JLabel("Status");
pa.add(responseLabel);
pa.add(response);
pa.add(statusLabel);
pa.add(status);
JPanel pb = new JPanel();
/*to handle pages of larger size were gonna need a scroll bar
*use a text areato define the size of the viewable area an pass
*it to a scroll pane object this has its own layout manager which handles
the scroll*/
display = new JTextArea(20,190);
displayHolder = new JScrollPaneDisplay(display);
Font f = new Font("Courier", Font.PLAIN, 12);
display.setFont(f);
display.setEditable(false);
pb.add(displayHolder);
p.add("North", pa);
p.add("Center", pb);
JPanel p1 = new Jpanel();
b = new JButton("Load");
l = new Loader();
locLabel = newJLabel("Url to be loaded: ");
locDisplay = new JTextField(45);
p1.setBackground(Color.lightGray);
p1.add(b);
p1.add(locLabel);
p1.add(locDisplay);
JPanel p2 = new JPanel();
typeLabel = new JLabel("Content type");
contentType = new JTextField("File Size: ");
contentType.setEditable(false);
sizeLabel = new JLabel("Fle Size");
size = new JTextField(6);size.setEditable(false);
p2.setBackground(Color.lightGray);
p2.add(typeLabel);
p2.add(contentLabel);
p2.add(sizeLabel);
p2.add(size);
p2.add(modifiedLabel);
p2.add(modified);
c.add("Center", p);
c.add("North", p1);
c.add("South", p2);
this.addWindowListener(new WindowAdapter() {
public void WindowClosing(WindowEvent e)
{
System.exit(0);
}
}); //end innner class declaration
public static void main(String[] args);
{
JFrame f = new Browser();
f.setSize(900,500);
f.setVisible(true);
}
//inner class definition substantial amount of code here
class Loader implements ActionListener
{
public void actionPerformed(ActionEvent e);
{
URL target = null;
String contents = null;
String type = null;
String server = null;
Date date = null;
int length = 0;
//start the loop
try
{
//read the users text from the location field
target = new URL(locDisplay.getText());
//lets the user know that we are working on the issue at hand
status.setText("Finding: " + target);
/* initialize an HttpURLCorrection object when
*correction is made*/
//use HttpURLCorrection to get response
server = fetch.setResponseMessage();
//pass the response for display to the user
response.setText(server);
BufferedReader in = new BufferedReader(new InputStreamReader(fetch.getInputStream()));
//let the user know that " huston we hava data packets incoming"
status.setText("Loading....");
/*prepare a character array to hold 1kb of data from buffered reader*/
char[] buffer = new char[1024];
int charsRead;
//send data from the bufferd reader to th character array
while((charsRead = in.read(buffer, 0, 1024)) != -1);
{
//put character into a data string
contents = new String(buffer, 0, charsRead);
display.append(contents);
}
//leaving this loop requires in.read() to return to -1 wich assumes no
more data is being transferred
status.setText("Done. Awaiting you Command");
//interrogate output stream headers
type = fetch.getContentType();
length = fetch.getContentLength();
date = new Date(fetch.getastModified());
//print information to the approiate feilds
contentType.setText(type);
size.setText(Interger.toString());
}
}//end method
}//end inner class
}//end class
thaanks in advance
-
Re: A prog i wrote and i cant fix
Tell us what the program is supposed to do and what error messages you get!!!!!!!
Ako
"Desperado" <planetvegita@dbzmail.com> wrote:
>
>if u can fix this prog please email me at
>planetvegita@dbzmail.com
>
>heres the prog
>
>
>import java.io.*;
>import java.net.*;
>import java.awt.*;
>import java.awt.event.*;
>import javax.swing.*;
>import java.util.*;
>
>class Browser extends JFrame
>{
> //declare all HCI elements
> private JLabel locLabel, responseLabel, statusLabel, typeLabel, sizeLabel,
>modifiedLabel;
> private JTextField locDisplay, response, status, contentType, size, modified;
> private JButton b;
> private JScrollPane displayHolder;
> private JTextArea display;
> private ActionListener l;
>
> public Browser()
> {
> Container c = getContentPane();
> this.setTitle("Http Text Browser Made With Java by CJW");
>
> JPanel p = new JPanel();
> p.setLayout(new BorderLayout());
>
> JPanel pa = new JPanel();
> pa.setBackground(Color.lightGray);
> responseLabel = new JLabel("Pinged Server Response");
> response = new JTextField(20);
> response.setEditable(false);
> statusLabel = new JLabel("Status");
> pa.add(responseLabel);
> pa.add(response);
> pa.add(statusLabel);
> pa.add(status);
> JPanel pb = new JPanel();
> /*to handle pages of larger size were gonna need a scroll bar
> *use a text areato define the size of the viewable area an pass
> *it to a scroll pane object this has its own layout manager which handles
>the scroll*/
>
> display = new JTextArea(20,190);
> displayHolder = new JScrollPaneDisplay(display);
> Font f = new Font("Courier", Font.PLAIN, 12);
> display.setFont(f);
> display.setEditable(false);
> pb.add(displayHolder);
>
> p.add("North", pa);
> p.add("Center", pb);
>
> JPanel p1 = new Jpanel();
> b = new JButton("Load");
> l = new Loader();
>
> locLabel = newJLabel("Url to be loaded: ");
> locDisplay = new JTextField(45);
>
> p1.setBackground(Color.lightGray);
> p1.add(b);
> p1.add(locLabel);
> p1.add(locDisplay);
> JPanel p2 = new JPanel();
> typeLabel = new JLabel("Content type");
> contentType = new JTextField("File Size: ");
> contentType.setEditable(false);
> sizeLabel = new JLabel("Fle Size");
> size = new JTextField(6);size.setEditable(false);
> p2.setBackground(Color.lightGray);
> p2.add(typeLabel);
> p2.add(contentLabel);
> p2.add(sizeLabel);
> p2.add(size);
> p2.add(modifiedLabel);
> p2.add(modified);
>
> c.add("Center", p);
> c.add("North", p1);
> c.add("South", p2);
>
> this.addWindowListener(new WindowAdapter() {
> public void WindowClosing(WindowEvent e)
> {
> System.exit(0);
> }
>
> }); //end innner class declaration
>
> public static void main(String[] args);
> {
> JFrame f = new Browser();
> f.setSize(900,500);
> f.setVisible(true);
> }
> //inner class definition substantial amount of code here
>
> class Loader implements ActionListener
> {
> public void actionPerformed(ActionEvent e);
> {
> URL target = null;
> String contents = null;
> String type = null;
> String server = null;
> Date date = null;
> int length = 0;
>
>
> //start the loop
>
> try
> {
> //read the users text from the location field
> target = new URL(locDisplay.getText());
>
> //lets the user know that we are working on the issue at hand
> status.setText("Finding: " + target);
>
> /* initialize an HttpURLCorrection object when
> *correction is made*/
>
> //use HttpURLCorrection to get response
> server = fetch.setResponseMessage();
>
> //pass the response for display to the user
> response.setText(server);
>
> BufferedReader in = new BufferedReader(new InputStreamReader(fetch.getInputStream()));
>
> //let the user know that " huston we hava data packets incoming"
> status.setText("Loading....");
>
> /*prepare a character array to hold 1kb of data from buffered reader*/
>
> char[] buffer = new char[1024];
> int charsRead;
>
> //send data from the bufferd reader to th character array
> while((charsRead = in.read(buffer, 0, 1024)) != -1);
> {
> //put character into a data string
> contents = new String(buffer, 0, charsRead);
> display.append(contents);
> }
>
> //leaving this loop requires in.read() to return to -1 wich assumes no
>more data is being transferred
>
>
> status.setText("Done. Awaiting you Command");
>
> //interrogate output stream headers
> type = fetch.getContentType();
> length = fetch.getContentLength();
> date = new Date(fetch.getastModified());
>
> //print information to the approiate feilds
> contentType.setText(type);
> size.setText(Interger.toString());
> }
> }//end method
> }//end inner class
>}//end class
>
>thaanks in advance
-
Re: A prog i wrote and i cant fix
No, the problem with that code is that it has numerous syntax errors and
won't compile.
PC2
"Ako" <ays73@hotmail.com> wrote in message news:3b52e7e3$1@news.devx.com...
>
> Tell us what the program is supposed to do and what error messages you
get!!!!!!!
>
>
> Ako
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks