-
May 14th, 2013, 06:46 AM
#1
Java Image Query Problem
Hello. I am posting here, as I am having a problem, maybe more. What I am trying to do is to emulate a Google Image Search.
I found a way to do this by using no special APIs as I am completely unfamiliar to this kind of practice. What I am trying to do in order to grab an image query
is this:
Append my query term to the following link:
http://ajax.googleapis.com/ajax/serv...mages?v=1.0&q=
You can see the actual page here:
http://ajax.googleapis.com/ajax/serv...?v=1.0&q=panda
This will return a result like:
Code:
{"responseData": {"results":[{"GsearchResultClass":"GimageSearch","width":"640","height":"480","imageId":"ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc","tbWidth":"137","tbHeight":"103","unescapedUrl":"http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg?1345515244","url":"http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg%3F1345515244","visibleUrl":"worldwildlife.org","title":"Giant \u003cb\u003ePanda\u003c/b\u003e | Species | WWF","titleNoFormatting":"Giant Panda | Species | WWF","originalContextUrl":"http://worldwildlife.org/species/giant-panda","content":"Giant \u003cb\u003ePanda\u003c/b\u003e","contentNoFormatting":"Giant Panda","tbUrl":"http://t0.gstatic.com/images?q\u003dtbn:ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc"},{"GsearchResultClass":"GimageSearch","width":"606","height":"387","imageId":"ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU","tbWidth":"136","tbHeight":"87","unescapedUrl":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg","url":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg","visibleUrl":"articles.washingtonpost.com","title":"National Zoo welcomes baby \u003cb\u003epanda\u003c/b\u003e - Washington Post","titleNoFormatting":"National Zoo welcomes baby panda - Washington Post","originalContextUrl":"http://articles.washingtonpost.com/2012-09-17/local/35498108_1_panda-cub-panda-reproduction-baby-panda","content":"Zoo welcomes baby \u003cb\u003epanda\u003c/b\u003e","contentNoFormatting":"Zoo welcomes baby panda","tbUrl":"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU"},{"GsearchResultClass":"GimageSearch","width":"948","height":"964","imageId":"ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT","tbWidth":"146","tbHeight":"148","unescapedUrl":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg","url":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg","visibleUrl":"www.npr.org","title":"What The \u003cb\u003ePanda\u003c/b\u003e Won\u0026#39;t Tell Us : Krulwich Wonders... : NPR","titleNoFormatting":"What The Panda Won\u0026#39;t Tell Us : Krulwich Wonders... : NPR","originalContextUrl":"http://www.npr.org/blogs/krulwich/2012/01/03/144633582/what-the-panda-won-t-tell-us","content":"Every giant \u003cb\u003epanda\u003c/b\u003e, said","contentNoFormatting":"Every giant panda, said","tbUrl":"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT"},{"GsearchResultClass":"GimageSearch","width":"948","height":"711","imageId":"ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA","tbWidth":"148","tbHeight":"111","unescapedUrl":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg","url":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg","visibleUrl":"www.npr.org","title":"Why The Animal Critic Gives The \u003cb\u003ePanda\u003c/b\u003e An F : NPR","titleNoFormatting":"Why The Animal Critic Gives The Panda An F : NPR","originalContextUrl":"http://www.npr.org/templates/story/story.php?storyId\u003d125773728","content":"A \u003cb\u003epanda\u003c/b\u003e. iStockphoto.com","contentNoFormatting":"A panda. iStockphoto.com","tbUrl":"http://t3.gstatic.com/images?q\u003dtbn:ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA"}],"cursor":{"resultCount":"428,000,000","pages":[{"start":"0","label":1},{"start":"4","label":2},{"start":"8","label":3},{"start":"12","label":4},{"start":"16","label":5},{"start":"20","label":6},{"start":"24","label":7},{"start":"28","label":8}],"estimatedResultCount":"428000000","currentPageIndex":0,"moreResultsUrl":"http://www.google.com/images?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den\u0026q\u003dpanda","searchResultTime":"0.24"}}, "responseDetails": null, "responseStatus": 200}
for Querying the term "panda"
The Result itself might seem confusing at first, but by filtering it with the following regex a much more clear list of results can be displayed.
(\"http\\S+?jpg\")
After applying this regex a list like the following can be extracted:
"http://t0.gstatic.com/images?q\u003dtbn:ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc"},{"GsearchResultClass":"GimageSearch","width":"606","height":"387","imageId":"ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU","tbWidth":"136","tbHeight":"87","unescapedUrl":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg"
"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg"
"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU"},{"GsearchResultClass":"GimageSearch","width":"948","height":"964","imageId":"ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT","tbWidth":"146","tbHeight":"148","unescapedUrl":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg"
"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg"
"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT"},{"GsearchResultClass":"GimageSearch","width":"948","height":"711","imageId":"ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA","tbWidth":"148","tbHeight":"111","unescapedUrl":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg"
"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg"
As you can easily tell, not all URLs are valid, but there are 2 or 3 that could be used.
What I am trying to do is extracting a list of "potential valid URLs" and then try to make labels with imageIcons extracted off the valid links.
This is my code so far.
Code:
import java.awt.BorderLayout;
public class browser extends JFrame {
private JPanel contentPane;
private JTextField textField;
/**
* Create the frame.
*/
public browser() {
setBounds(100, 100, 450, 300);
setVisible(true);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
textField = new JTextField();
textField.setBounds(6, 11, 390, 28);
contentPane.add(textField);
textField.setColumns(10);
mainFrame mOb = new mainFrame();
JButton search = new JButton("");
search.setIcon(new ImageIcon("C:\\Users\\Mihai\\Desktop\\search-icon.png"));
search.setBounds(397, 11, 31, 28);
contentPane.add(search);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(6, 51, 422, 205);
contentPane.add(scrollPane);
scrollPane.getViewport().setOpaque(false);
final JPanel editorPane = new JPanel();
scrollPane.setViewportView(editorPane);
editorPane.setOpaque(false);
editorPane.setBackground(new Color(0,0,0,0));
JLabel background = new JLabel("");
background.setBounds(0, 0, 434, 262);
contentPane.add(background);
background.setIcon(mOb.BG);
final JEditorPane editorPane_1 = new JEditorPane();
editorPane_1.setBounds(6, 35, 0, 0);
contentPane.add(editorPane_1);
editorPane.setLayout(new FlowLayout());
//SEARCH LISTENER
search.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String query = textField.getText();
// VALID SEARCH
if(query!=""){
String rawString="";
try{
URL rawURL = new URL("http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q="+query);
editorPane_1.setPage(rawURL);
rawString = editorPane_1.getText().replaceAll("\n", System.getProperty("line.separator"));
editorPane_1.setText("");
System.out.println(rawString);
}catch(Exception ex){
ex.printStackTrace();
System.out.println("FIRST BLOCK ");
}
//GET NUMBER OF LINKS
Pattern pattern = Pattern.compile("(\"http\\S+?jpg\")");
Matcher matcher = pattern.matcher(rawString);
int j = 0;
while (matcher.find()) {
j++;
}
String refString[] = new String[j];
//ASSIGN LINKS
Pattern pattern2 = Pattern.compile("(\"http\\S+?jpg\")");
Matcher matcher2 = pattern.matcher(rawString);
int k =0;
while (matcher2.find()) {
refString[k]=matcher2.group().toString();
System.out.println(refString[k]);
}
//INSERT PROPER REGEX
int i = 0;
for(i = 0; i<refString.length; i++){
JLabel label= new JLabel("SUP");
label.setPreferredSize(new Dimension(200,100));
try{
URL url = new URL(refString[i].trim());
ImageIcon icon = new ImageIcon(ImageIO.read(url));
label.setIcon(icon);
}catch(Exception ex){
ex.printStackTrace();
continue;
}
System.out.println("\n FINISHED BLOCK!!!! ");
editorPane.add(new JScrollPane(label));
}
}
}
});
}
}
Last edited by cens; May 14th, 2013 at 06:49 AM.
-
May 14th, 2013, 06:51 AM
#2
Re: Java Image Query Problem
Upon making a query for the Term "panda" the following rresults are displayed
Code:
{"responseData": {"results":[{"GsearchResultClass":"GimageSearch","width":"640","height":"480","imageId":"ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc","tbWidth":"137","tbHeight":"103","unescapedUrl":"http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg?1345515244","url":"http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg%3F1345515244","visibleUrl":"worldwildlife.org","title":"Giant \u003cb\u003ePanda\u003c/b\u003e | Species | WWF","titleNoFormatting":"Giant Panda | Species | WWF","originalContextUrl":"http://worldwildlife.org/species/giant-panda","content":"Giant \u003cb\u003ePanda\u003c/b\u003e","contentNoFormatting":"Giant Panda","tbUrl":"http://t0.gstatic.com/images?q\u003dtbn:ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc"},{"GsearchResultClass":"GimageSearch","width":"606","height":"387","imageId":"ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU","tbWidth":"136","tbHeight":"87","unescapedUrl":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg","url":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg","visibleUrl":"articles.washingtonpost.com","title":"National Zoo welcomes baby \u003cb\u003epanda\u003c/b\u003e - Washington Post","titleNoFormatting":"National Zoo welcomes baby panda - Washington Post","originalContextUrl":"http://articles.washingtonpost.com/2012-09-17/local/35498108_1_panda-cub-panda-reproduction-baby-panda","content":"Zoo welcomes baby \u003cb\u003epanda\u003c/b\u003e","contentNoFormatting":"Zoo welcomes baby panda","tbUrl":"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU"},{"GsearchResultClass":"GimageSearch","width":"948","height":"964","imageId":"ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT","tbWidth":"146","tbHeight":"148","unescapedUrl":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg","url":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg","visibleUrl":"www.npr.org","title":"What The \u003cb\u003ePanda\u003c/b\u003e Won\u0026#39;t Tell Us : Krulwich Wonders... : NPR","titleNoFormatting":"What The Panda Won\u0026#39;t Tell Us : Krulwich Wonders... : NPR","originalContextUrl":"http://www.npr.org/blogs/krulwich/2012/01/03/144633582/what-the-panda-won-t-tell-us","content":"Every giant \u003cb\u003epanda\u003c/b\u003e, said","contentNoFormatting":"Every giant panda, said","tbUrl":"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT"},{"GsearchResultClass":"GimageSearch","width":"948","height":"711","imageId":"ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA","tbWidth":"148","tbHeight":"111","unescapedUrl":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg","url":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg","visibleUrl":"www.npr.org","title":"Why The Animal Critic Gives The \u003cb\u003ePanda\u003c/b\u003e An F : NPR","titleNoFormatting":"Why The Animal Critic Gives The Panda An F : NPR","originalContextUrl":"http://www.npr.org/templates/story/story.php?storyId\u003d125773728","content":"A \u003cb\u003epanda\u003c/b\u003e. iStockphoto.com","contentNoFormatting":"A panda. iStockphoto.com","tbUrl":"http://t3.gstatic.com/images?q\u003dtbn:ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA"}],"cursor":{"resultCount":"428,000,000","pages":[{"start":"0","label":1},{"start":"4","label":2},{"start":"8","label":3},{"start":"12","label":4},{"start":"16","label":5},{"start":"20","label":6},{"start":"24","label":7},{"start":"28","label":8}],"estimatedResultCount":"428000000","currentPageIndex":0,"moreResultsUrl":"http://www.google.com/images?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den\u0026q\u003dpanda","searchResultTime":"0.10"}}, "responseDetails": null, "responseStatus": 200}
"http://t0.gstatic.com/images?q\u003dtbn:ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc"},{"GsearchResultClass":"GimageSearch","width":"606","height":"387","imageId":"ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU","tbWidth":"136","tbHeight":"87","unescapedUrl":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg"
"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg"
"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU"},{"GsearchResultClass":"GimageSearch","width":"948","height":"964","imageId":"ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT","tbWidth":"146","tbHeight":"148","unescapedUrl":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg"
"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg"
"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT"},{"GsearchResultClass":"GimageSearch","width":"948","height":"711","imageId":"ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA","tbWidth":"148","tbHeight":"111","unescapedUrl":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg"
"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg"
Code:
java.net.MalformedURLException: no protocol: "http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg"
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at browser$1.actionPerformed(browser.java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
at browser$1.actionPerformed(browser.java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
at browser$1.actionPerformed(browser.java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
at browser$1.actionPerformed(browser.java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
at browser$1.actionPerformed(browser.java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
//I have deleted one of the exceptions as i should limit myself to 20000 characters per post, but it's essentially the same as the other null-pointers
The first line is the raw query, the nest 6 are "potentially valid URLs" and the code following is a series of exceptions. You can observe that The first exception refers to a malformed URL exception, while all the others refer to null-pointer exceptions.
I am curious and seeking help about the following:
•Why is the sequence of exceptions like it is?
•Can you help me design a better RegEx to grab valid URLs?
•Is there a better, and not very complicated way of doing the same thing(making an image query) without all this trouble?
Thank you so much for your time!
-Cens
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
|
Click Here to Expand Forum to Full Width
|