Open URL on a specific tab irrespective of any type of browser Java -
hi have java program. have tried mimic actual program sample code below requirement:
import java.awt.*; import java.awt.event.*; import java.io.ioexception; import javax.swing.*; import java.awt.desktop; import java.io.unsupportedencodingexception; import java.net.uri; import java.net.urisyntaxexception; class simpletableexample extends jframe { private jpanel pmainmenu = null; public simpletableexample() { pmainmenu = new jpanel(); borderlayout thislayout = new borderlayout(); pmainmenu.setlayout(thislayout); { jpanel pbuttons = new jpanel(); pmainmenu.add(pbuttons, borderlayout.north); jbutton btnew = new jbutton(); pbuttons.add(btnew, new gridbagconstraints(2, 0, 1, 1, 0.0, 0.0, gridbagconstraints.center, gridbagconstraints.none, new insets(0, 5, 0, 0), 0, 0)); btnew.settext("<html><center>open</center><center>urls</center></html>"); btnew.addactionlistener(new actionlistener() { public void actionperformed(actionevent evt) { btrunconfiguration(evt); } }); } getcontentpane().add(pmainmenu); getcontentpane().repaint(); pack(); setsize(520, 130); setlocationrelativeto(null); setvisible(true); } private void btrunconfiguration(actionevent evt) { getcontentpane().removeall(); for(int j=0;j<2;j++) { (int = 0; < 5; i++) { try { desktop desktop = desktop.isdesktopsupported() ? desktop.getdesktop() : null; string url = "http://stackoverflow.com"; desktop.browse(new uri(url)); thread.sleep(2000); } catch (interruptedexception ie) { ie.printstacktrace(); } catch (ioexception le) { le.printstacktrace(); } catch(urisyntaxexception e) { e.printstacktrace(); } } } } public static void main( string args[] ) { simpletableexample mainframe = new simpletableexample(); mainframe.setvisible( true ); } }
it opens few urls in loop. say, have 5 different urls open in 5 different tabs. here in sample program using same url, in actual program different. ---for (int = 0; < 5; i++) reopens again same urls in outer loop. ---for(int j=0;j<2;j++) reopen 5 urls in same tabs again open in. urls google maps in actual program change every few seconds.
can please help. thanks. appreciate it.
Comments
Post a Comment