Java Reference
In-Depth Information
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
class ViewChart
{
final
static
String
BASEURI
=
"ht-
tps://chart.googleapis.com/chart?";
public static void main(String[] args)
{
String qs =
"cht=p3&chs=450x200&chd=t:60,40&chl=q1%20(60%)|q2%20(40%)";
ImageIcon ii = doGet(qs);
if (ii != null)
{
JFrame frame = new JFrame("viewchart");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new JLabel(ii));
frame.pack();
frame.setResizable(false);
frame.setVisible(true);
}
}
static ImageIcon doGet(String qs)
{
try
{
URL url = new URL(BASEURI+qs);
HttpURLConnection httpurlc;
httpurlc
=
(HttpURLConnection)
url.openConnection();
httpurlc.setRequestMethod("get");
httpurlc.setDoInput(true);
if (httpurlc.getResponseCode() == 200)
{
Search WWH ::




Custom Search