Statistics |
|
Total online: 1 Guests: 1 Users: 0 | |
|
|
| | |
|
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: 11012 | Comments: 2
| Tags: reender html, aplikasi java
| Rating: 0.0/0 |
Total comments: 1 | |
1
nisca
(2011-10-18 4:20 AM)
0
woowwwwwwwwwwwwwwwww bgmn qw bsa ngerti klo ni contoh semuax pakai bahasa ingles..hahahahahaha janda aja ni
|
|
|
|
| |
| | |
|
|