Contoh aplikasi web java - Java - Publisher - Royz Rambo
Ilham Penta
Site menu
Section categories
My articles [6]
Java [14]
Java Programming
Flash [6]
Flash
URL web dan Tutorial [29]
Petualangan [1]
Our poll
Rate my site
Total of answers: 19
Statistics

Total online: 2
Guests: 2
Users: 0
Login form
Main » Articles » Java

Contoh aplikasi web java
Menampilkan hasil reender html di Java App

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package capturehtml;

/**
 *
 * @author pentax
 */


import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;

public class captureHTML {

   JEditorPane editor;
   JScrollPane scrollEditor, scrollPanel;
   JPanel panel;
   JSplitPane split;
   JButton button;
   BufferedImage bi;

   void makeUI() {
      editor = new JEditorPane();
      try {
         editor.setPage("http://www.google.com");
      } catch (IOException ex) {
         ex.printStackTrace();
      }
      scrollEditor = new JScrollPane(editor);

      panel = new JPanel() {
         @Override
         public void paintComponent(Graphics g) {
            super.paintComponent(g);
            if (bi != null) {
               g.drawImage(bi, 0, 0, this);
            }
         }
      };
      scrollPanel = new JScrollPane(panel);

      split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollEditor, scrollPanel);
      split.setResizeWeight(0.5);

      button = new JButton("Click");
      button.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            bi = new BufferedImage(editor.getPreferredSize().width,
                  editor.getPreferredSize().height,
                  BufferedImage.TYPE_INT_RGB);
            Graphics g = bi.createGraphics();
            editor.paintAll(g);
            panel.setPreferredSize(editor.getPreferredSize());
            panel.revalidate();
            panel.repaint();
         }
      });

      JFrame frame = new JFrame("Web Page SnapShot");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(700, 500);
      frame.setLocationRelativeTo(null);

      frame.add(split);
      frame.add(button, BorderLayout.SOUTH);
      frame.setVisible(true);
   }

   public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
         public void run() {
            new captureHTML().makeUI();
         }
      });
   }
}



Source: http://forums.sun.com/thread.jspa?threadID=5293570
Category: Java | Added by: penta (2010-11-04)
Views: 1497 | Comments: 2 | Tags: reender html, aplikasi java | Rating: 0.0/0
Total comments: 1
1  
woowwwwwwwwwwwwwwwww bgmn qw bsa ngerti klo ni contoh semuax pakai bahasa ingles..hahahahahaha janda aja ni

Name *:
Email *:
Code *:
Search
Site friends
  • Create a free website
  • Copyright Penta.Inc © Powered By: Senjapala