Hi,
I am creating a very basic web browser using JEditorPane just to teach myself Swing and GUIs in Java but am having trouble implementing a Firefox-like Google Search bar.
I'm not if it's due to a limitation of JEditorPane or my lack of understanding but if I try and take the string typed into the "Google Search" bar and use the setPage() method of JEditorPane, it doesn't work.
Here is my code for the ActionListener of the "Google Search" button:
public void actionPerformed(ActionEvent arg0)
{
try
{
content.setPage("http://www.google.com/search?q=" + searchBar.getText());
}
catch (IOException e)
{
JOptionPane.showMessageDialog(frame, "Error searching for: " + searchBar.getText());
}
}
Even when I try and just do content.setPage("http://www.google.com/search?p=test"); it doesnt work, so is it something to do with setPage()'s way of taking the URL string? As in it doesn't like the "?" or "=" characters or is there another way of doing it all together?
Thanks for your time,
InfinitiFizz