Cybertronic
Technical User
- May 18, 2006
- 19
Hi all,
I apologise for creating another thread but I would love to have some help with my problem I'm currently having please.
I've created a web browser in Java where I have several different classes to help separate the code for ease of coding. I'm currently stuck on a Java class issue where I trying to code the backwards and forwards buttons in my browser.
I've got the HyperlinkHandler class below:
and the historyResize method in a class called ToolBar:
The bold line of code in the HyperlinkHandler class above is currently giving me problems where my Java software comes up with an error saying:
If I change private to public it'll then say the following:
If I include static in the historyResize method, some of my variables within that method will come up with a similar error as above
After trying those, I tried declaring an instance of the ToolBar class in the HyperlinkHandler class:
This compiles fine but if I try to click on a link I get "java.lang.NullPointerException" errors
I'm really lost here and can anybody please help me?
I appreciate anybody's help
I apologise for creating another thread but I would love to have some help with my problem I'm currently having please.
I've created a web browser in Java where I have several different classes to help separate the code for ease of coding. I'm currently stuck on a Java class issue where I trying to code the backwards and forwards buttons in my browser.
I've got the HyperlinkHandler class below:
Code:
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.io.IOException;
public class HyperlinkHandler implements HyperlinkListener
{
JEditorPane contentPane;
JToolBar toolBar;
public void hyperlinkUpdate(HyperlinkEvent event)
{
// String address = addressTextField.getText();
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
[b]ToolBar.historyResize("" + event.getURL());[/b]
// toolBar.showURL("" + event.getURL());
try
{
contentPane = (JEditorPane) event.getSource();
contentPane.setPage(event.getURL());
// toolBar.addressTextField.setText(event.getURL().toExternalForm());
}
catch (IOException ioe)
{
JOptionPane.showMessageDialog(null,
"Java Web Browser can't find the server at " + ioe,
"Java Web Browser",
JOptionPane.ERROR_MESSAGE);
}
}
}
and the historyResize method in a class called ToolBar:
Code:
private void historyResize(String url)
{
historyActive++;
history[historyActive] = url;
historySize = historyActive + 1;
if (historySize == historyMax)
{
historyMax += 10;
String temp[] = new String[historyMax];
for (int i = 0; i < historySize; i++)
{
temp[i] = history[i];
}
history = temp;
}
buttonCheck();
}
The bold line of code in the HyperlinkHandler class above is currently giving me problems where my Java software comes up with an error saying:
historyResize(java.lang.String) has private access in ToolBar
If I change private to public it'll then say the following:
Non-static method historyResize(java.lang.String) cannot be referenced from a static context
If I include static in the historyResize method, some of my variables within that method will come up with a similar error as above
After trying those, I tried declaring an instance of the ToolBar class in the HyperlinkHandler class:
ToolBar toolBar = new ToolBar(contentPane, browserPanel);
This compiles fine but if I try to click on a link I get "java.lang.NullPointerException" errors
I'm really lost here and can anybody please help me?
I appreciate anybody's help