Opening IE from Java Swing Application in Kiosk mode
Hi All,
I want to open a URL in IE from my Java Swing application running in Wiindows. I am using the below code.
public static boolean openInBrowserKioskMode(String url){
String os = System.getProperty("os.name").toLowerCase();
Runtime rt = Runtime.getRuntime();
try{
if (os.indexOf( "win" ) >= 0) {
rt.exec( "rundll32 url.dll,FileProtocolHandler " + url);
}
}catch (IOException e){
e.printStackTrace();
return false;
}
return true;
}
As per the above code, IE window is opening. But I want to open the IE window in Kiosk mode or without address bar, foward/back buttons, etc. Please help me to resolve this problem
Thanks & Regards,
Abhijith
View Answers
November 7, 2012 at 3:41 PM
Here is a simple example of opening IE in swing application.
class OpenBrowser
{
public static void main(String[] args)
{
String browserPath = "C:/Program Files/Internet Explorer/IEXPLORE.EXE";
String url = "www.roseindia.net";
try {
String[] b = {browserPath, url};
Runtime.getRuntime().exec(b);
}
catch (Exception exc) {
exc.printStackTrace();
}
}
}
November 7, 2012 at 3:42 PM
Here is a simple example of opening browser in swing application.
1)OpenBrowser.java
import javax.swing.*;
import java.lang.reflect.Method;
public class OpenBrowser {
public static void openURL(String url) {
String osName = System.getProperty("os.name");
try {
if (osName.startsWith("Windows"))
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
else {
String[] browsers = {"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
String browser = null;
for (int count = 0; count < browsers.length && browser == null; count++)
if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor() == 0)
browser = browsers[count];
Runtime.getRuntime().exec(new String[] {browser, url});
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error in opening browser" + ":\n" + e.getLocalizedMessage());
}
}
}
2)Browser.java
import javax.swing.*;
import java.awt.event.*;
public class Browser {
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
final JTextField url =new JTextField(20);
JButton button = new JButton("Open Browser");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
OpenBrowser.openURL(url.getText().trim());
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel.add(new JLabel("URL:"));
panel.add(url);
panel.add(button);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
}
November 7, 2012 at 3:42 PM
Here is a simple example of opening browser in swing application.
1)OpenBrowser.java
import javax.swing.*;
import java.lang.reflect.Method;
public class OpenBrowser {
public static void openURL(String url) {
String osName = System.getProperty("os.name");
try {
if (osName.startsWith("Windows"))
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
else {
String[] browsers = {"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
String browser = null;
for (int count = 0; count < browsers.length && browser == null; count++)
if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor() == 0)
browser = browsers[count];
Runtime.getRuntime().exec(new String[] {browser, url});
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error in opening browser" + ":\n" + e.getLocalizedMessage());
}
}
}
2)Browser.java
import javax.swing.*;
import java.awt.event.*;
public class Browser {
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
final JTextField url =new JTextField(20);
JButton button = new JButton("Open Browser");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
OpenBrowser.openURL(url.getText().trim());
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel.add(new JLabel("URL:"));
panel.add(url);
panel.add(button);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
}
Ads
Related Tutorials/Questions & Answers:
Opening IE from Java Swing Application in Kiosk mode
Opening IE from Java Swing Application in
Kiosk mode Hi All,
I want to open a URL in
IE from my
Java Swing application running in Wiindows. I am... window is
opening. But I want to open the
IE window in
Kiosk mode or without address
How to run java swing application from jar files .
How to run
java swing application from jar files . Hello Sir,
I developed a
java swing application .Now i want to execute it as .exe... the main class program will exit"
from "
java virtual machine".
Plz help me
Advertisements
Opening a browser only with body from a java program
Opening a browser only with body
from a
java program Hi all,
I got following requirement,
Opening a browser window only with body and title bar... { //attempt to use Desktop library
from JDK 1.6+
Class<?> d = Class.forName
Retrieve data from database in swing application
Retrieve data
from database in
swing application I want to retrive data(doctor name,specilization,date)
from my sql database...();
ResultSet rs=st.executeQuery("select *
from data where id=1");
while
Threads in Java Swing MVC Application
Threads in
Java Swing MVC Application Hello, I am currently making a
Java Swing application, but I am having a lot of trouble with implementing threads into my program.
I use the MVC paradigm and I just can't seem to implement
catching tomcat object to swing application
catching tomcat object to
swing application Hi, I have 2
java projects, one is running on tomcat server and another is at client pc
ie swing application. So I need to catch a server side object
from swing application. How can I
Swing Application
Swing Application hello,
i am making
swing application in
java i am unable to run prog......when my rite clikcing on my project name and clicking thn run it is not showing output .....and when i am cliking on individual
java
Swing application
Swing application Hello, I want to develop a
Swing application... the
application not through web browsers, instead through a
Swing desktop
application GUIs. Please help me to develop such an
application
Java - Opening a URL from an Applet
Java -
Opening a URL
from an Applet
This is the example of
opening a url in same... used for
opening url
from an applet. This program is using two functions
Opening a URL from an Applet
Opening a URL
from an Applet
Introduction
This is the example of
opening a url in same... used for
opening url
from an applet. This program is using two functions in which
swing application to import a object in a excel
swing application to import a object in a excel Hi sir, I want to make a
swing application where I can import a object in a cell of a excel... 'create
from file' window>browse (this browse path I want to give inside the
swing
java swing.
java swing. Hi
How SetBounds is used in
java programs.The values in the setBounds refer to what?
ie for example setBounds(30,30,30,30) and in that the four 30's refer to what
Swing Application help
Swing Application help Hi am developing an
application. I have set up an ADD button, which if clicked should open the add information form...;Here is a
swing application that will insert the form data into database
Chess Application In Java Swing
.style1 {
margin-right: 0px;
}
Chess
Application In
Java Swing
In this section, you will learn how to create chess game in
java swing
opening new browser with new JSESSIONID using java
opening new browser with new JSESSIONID using java I am facing following problem, I am trying to open a new browser using
java. First i have opened one
IE browser and manually. And i ran my LaunchURL.java file, it is
opening new
Java swing
Java swing Write a
java swing program to calculate the age
from given date of birth
How To Pass data from one GUI to another in java swing
How To Pass data
from one GUI to another in
java swing I'm new to
java and part of our assignment is to build a GUI and display a result set
from data input. I'm stuck at how to get the user's input
from JTextFields and combobox
Java - Opening a url in new window from an applet
Java -
Opening a url in new window
from an applet
 ... how to open a new window
from an applet. You can use the code given... will open new browser window and then show you the web page.
Opening a new