forked from kishanrajput23/Java-Projects-Collections
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOxygenBrowser.java
More file actions
63 lines (58 loc) · 1.87 KB
/
OxygenBrowser.java
File metadata and controls
63 lines (58 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
public class OxygenBrowser extends JFrame{
JTextField t1;
JEditorPane display;
public OxygenBrowser(){
super("Ram Ji Ka Browser");
t1=new JTextField();
t1.setText("Enter Host..!");
t1.setFont(new Font("Berlin Sans FB",Font.PLAIN,15));
t1.setForeground(Color.BLUE);
t1.addMouseListener(new MouseAdapter(){
@Override
public void mouseClicked(MouseEvent e){
t1.setText("");
}
});
t1.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e){
loadCrap(e.getActionCommand());
}
});
add(t1,BorderLayout.NORTH);
display=new JEditorPane();
display.setEditable(false);
display.addHyperlinkListener(new HyperlinkListener(){
public void hyperlinkUpdate(HyperlinkEvent event){
if(event.getEventType()==HyperlinkEvent.EventType.ACTIVATED)
{
loadCrap(event.getURL().toString());
}
}
});
add(new JScrollPane(display), BorderLayout.CENTER);
setSize(700,600);
setLocation(300,100);
setVisible(true);
}
public void loadCrap(String userText)
{
try{
display.setPage(userText);
t1.setText(userText);
}
catch(Exception e){
System.out.println("Crap..!");
String dialogmessage="Error";
String dialogtittle="Type valid Host( \n Ex. - (http://www.google.com) \n Or Cheak Internet Connection";
int dialogtype=JOptionPane.WARNING_MESSAGE;
JOptionPane.showMessageDialog((Component)null, dialogtittle,dialogmessage,dialogtype);
}
}
}