summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/test/simplebrowser/KSimpleBrowser.java
blob: 051dfeab5648cff33da4ba193a903a8e317beee2 (plain)
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
import org.kde.qt.*;
import org.kde.koala.*;

/**
 *  Class KSimpleBrowser is the main application window.
 *
 *  Taken from KDE 2.0 Development book
 *
 *  Rendering HTML Files
 *
 *  A Simple Web Browser - A feature-limited Web Browser.
 *
 * @see KMainWindow
 * @see TDEApplication
 * @see KHTMLPart
 *
 * @author java translation Kenneth J. Pouncey, kjpou@hotmail.com
 * @version 0.1
 */

public class KSimpleBrowser extends KMainWindow {


   static final int URLLined = 1;

   KHTMLPart khtmlpart;

   public KSimpleBrowser (String name) {

      super(null,name,0);

      toolBar().insertLined( "", URLLined, SIGNAL("returnPressed()"),
               this, SLOT ("slotNewURL()"));


      toolBar().setItemAutoSized(URLLined);

      khtmlpart = new KHTMLPart(this);
      khtmlpart.begin();

      khtmlpart.write("<HTML><BODY><H1>KSimpleBrowser</H1>" +
                        "<P>To load a web page, type its URL in the line " +
                        "edit box and press enter,</P>" +
                        "</BODY></HTML>");

      khtmlpart.end();

      setCaption("KDE 2 Development book example - KSimpleBrowser");

      setCentralWidget(khtmlpart.view());

   }

   public void slotNewURL () {

      khtmlpart.openURL(new KURL(this.toolBar().getLinedText(URLLined)))   ;
   }


   static {
      qtjava.initialize();
      kdejava.initialize();
   }

}