Hitting the same URL with slight modifications made easy
Just copy a text and paste it in the textbox, the dialog box would append the content to your specified URL and open a new tab of the same in your web browser. This program is useful for those who have to hit almost the same URL again and again but with a slight modification somewhere in the URL itself.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;
class UrlFrame extends JFrame
{
JButton makeUrl;
JTextField url;
UrlFrame()
{
setTitle("Make
Url");
url = new JTextField(20);
makeUrl = new JButton("Make
Url");
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
panel.add(url);
panel.add(makeUrl);
makeUrl.addActionListener(new ActionListener() {
public void
actionPerformed(ActionEvent e)
{
openURL(url.getText());
}
});
add(panel);
setVisible(true);
setSize(400,300);
}
private void openURL(String
url)
{ // Configure the URL according to your requirement
try
{
Process p=Runtime.getRuntime().exec("rundll32
url.dll,FileProtocolHandler \"" + prodUrl + "\"");
}
catch(IOException e1)
{System.out.println(e1);}
}
}
public class MakeURL {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
new UrlFrame();
}
}
Comments
Post a Comment