i am trying to make a web browser and here is my code
CODE:
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.awt.event.*;
import java.applet.*;
public class browserPannel extends JFrame{
public static void main(String[] arg)
{
JFrame browser = new JFrame("A Nun In A Weelchair");
browser.setSize(1000,700);
browser.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
browser.setLocationRelativeTo(null);
browser.pack();
browser.setVisible(true);
JPanel header = new JPanel();
header.setBackground(Color.lightGray);
header.setVisible(true);
final JEditorPane htmlc = new JEditorPane();
htmlc.setBackground(Color.red);
htmlc.setEditable(true);
htmlc.setContentType("text/html");
htmlc.setVisible(true);
final JTextField url = new JTextField(20);
url.setSize(890,30);
url.setVisible(true);
url.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
loadHtml(htmlc, url, event.getActionCommand());
System.out.println("action performed");
}
}
);
JButton send = new JButton("Send");
send.setSize(75,30);
send.setVisible(true);
header.add(url, BorderLayout.SOUTH);
header.add(send);
browser.getContentPane().add(header, BorderLayout.NORTH);
browser.getContentPane().add(new JScrollPane(htmlc));
}
private void loadHtml(JEditorPane htmlc, JTextField url, String link)
{
try{
htmlc.setPage(link);
url.setText(link);
}catch(Exception e){
System.out.println("ops sorry could not fined Virgine Mobile");
e.printStackTrace();
}
}
}
and here is my error message:
browserPannel.java:38: error: non-static method loadHtml(JEditorPane,JTextField,
String) cannot be referenced from a static context
loadHtml(htmlc, url, event.getActionComm
and());
^
1 error
as you can tell it is getting errors from the loadHtml which is defined in a method at the buttom of my code, now if i remove the loadHtml, then it displays the println("action Performed");, but only when i refer the loadHtml it says that it that the non static method can not be preformed in a static method.