当前位置: 技术问答>java相关
disk请进,加分
来源: 互联网 发布时间:2015-06-25
本文导语: 只有60了 | 不知道这段代码和你的想法是否一样 import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.net.*; public class TUEditorPane extends JFrame implements ActionListen...
只有60了
|
不知道这段代码和你的想法是否一样
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class TUEditorPane extends JFrame implements ActionListener {
JEditorPane edit;
JTextField text;
URL page;
public TUEditorPane() {
super("fds");
setSize(500, 400);
Container c = getContentPane();
JButton b = new JButton("link");
JLabel lbel1 = new JLabel("UrlAddress:");
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
p.add(lbel1);
text = new JTextField(32);
text.addActionListener(this);
b.addActionListener(this);
p.add(text);
p.add(b);
c.add(p, BorderLayout.NORTH);
edit = new JEditorPane();
JScrollPane js = new JScrollPane(edit);
edit.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent eh) {
try {
edit.setPage(eh.getURL());
} catch (Exception ej) {
}
}
});
c.add(js, BorderLayout.CENTER);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ew) {
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e) {
try {
page = new URL(text.getText());
} catch (java.io.IOException eio) {
System.out.println(eio);
}
try {
edit.setPage(page);
} catch (Exception ei) {
System.out.println(e);
}
}
public static void main(String args[]) {
TUEditorPane t = new TUEditorPane();
t.show();
}
}
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class TUEditorPane extends JFrame implements ActionListener {
JEditorPane edit;
JTextField text;
URL page;
public TUEditorPane() {
super("fds");
setSize(500, 400);
Container c = getContentPane();
JButton b = new JButton("link");
JLabel lbel1 = new JLabel("UrlAddress:");
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
p.add(lbel1);
text = new JTextField(32);
text.addActionListener(this);
b.addActionListener(this);
p.add(text);
p.add(b);
c.add(p, BorderLayout.NORTH);
edit = new JEditorPane();
JScrollPane js = new JScrollPane(edit);
edit.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent eh) {
try {
edit.setPage(eh.getURL());
} catch (Exception ej) {
}
}
});
c.add(js, BorderLayout.CENTER);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ew) {
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e) {
try {
page = new URL(text.getText());
} catch (java.io.IOException eio) {
System.out.println(eio);
}
try {
edit.setPage(page);
} catch (Exception ei) {
System.out.println(e);
}
}
public static void main(String args[]) {
TUEditorPane t = new TUEditorPane();
t.show();
}
}
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。