-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tarayici.java
165 lines (132 loc) · 3.37 KB
/
Tarayici.java
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.event.*;
public class Tarayici extends JFrame implements
ActionListener,HyperlinkListener
{
private JEditorPane webs;
private JScrollPane kay;
private JMenuBar menubar;
private JMenu menu,hakkimda;
private JMenuItem menukapa;
private Button kapat;
private Button yazdir;
private Button dugme;
private TextField kutu;
private URL url;
public Tarayici()
{
super("Tarayici");
setSize(950,700);
Container c=getContentPane();
dugme=new Button("Git");
dugme.addActionListener(this);
menubar=new JMenuBar();
menu=new JMenu("Dosya");
hakkimda=new JMenu("Hakk�mda");
hakkimda.addActionListener(this);
menukapa=new JMenuItem("òk�?");
menukapa.addActionListener(this);
menu.add(menukapa);
menubar.add(menu);
menubar.add(hakkimda);
kapat=new Button("Kapat");
kapat.addActionListener(this);
yazdir=new Button("Geri");
yazdir.addActionListener(this);
kutu=new TextField("http://www.");
kutu.addActionListener(this);
webs=new JEditorPane();
webs.setEditable(false);
webs.addHyperlinkListener(this);
setJMenuBar(menubar);
c.setLayout(null);
kay=new JScrollPane(webs);
kay.setBounds(10,50,940,650);
kutu.setBounds(10,20,740,25);
dugme.setBounds(751,20,50,25);
kapat.setBounds(803,20,50,25);
yazdir.setBounds(855,20,50,25);
c.add(kapat);
c.add(kay);
c.add(dugme);
c.add(yazdir);
c.add(kutu);
show();
}
public void actionPerformed(ActionEvent e)
{
setTitle("Kachak Web Tarayici - Site A��l�yor...");
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Object kaynak=e.getSource();
String satir=kutu.getText();
if (kaynak==dugme || kaynak==kutu)
{
try {
webs.setPage(satir);
setTitle("Kachak Web Tarayici - A��ld�");
}
catch (IOException ei)
{
try {
webs.setPage("http://www.cmaeal.com/hata/hata.html");
kutu.setText("hata: sayfaYok");
}
catch (IOException se) {
System.out.print("Hata oldu..");
}
}
}
else if (kaynak==kapat)
{
System.exit(0);
}
else if (kaynak==hakkimda)
{
JOptionPane.showMessageDialog( this,"S�r�m 1.0","Yazan: Can",JOptionPane.INFORMATION_MESSAGE );
}
else if (kaynak==menukapa)
{
System.exit(0);
}
else if (kaynak==yazdir)
{
try {
webs.setPage((String)yazdir.getEditor().getItem());
} catch (IOException ex) {
Logger.getLogger(Tarayici.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public void hyperlinkUpdate( HyperlinkEvent ea )
{
if ( ea.getEventType() ==
HyperlinkEvent.EventType.ACTIVATED )
{
try {
webs.setPage( ea.getURL().toString() );
kutu.setText(ea.getURL().toString());
}
catch (IOException ei)
{
try {
webs.setPage("http://www.cmaeal.com/hata/hata.html");
kutu.setText("hata: sayfaYok");
}
catch (IOException se) {
System.out.print("Hata oldu..");
}
}
}
}
public static void main(String[] args)
{
Tarayici t=new Tarayici();
t.setVisible(true);
}
}