summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/test/kmenu/KdeMenuSample.java
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kdejava/koala/test/kmenu/KdeMenuSample.java
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdejava/koala/test/kmenu/KdeMenuSample.java')
-rw-r--r--kdejava/koala/test/kmenu/KdeMenuSample.java142
1 files changed, 142 insertions, 0 deletions
diff --git a/kdejava/koala/test/kmenu/KdeMenuSample.java b/kdejava/koala/test/kmenu/KdeMenuSample.java
new file mode 100644
index 00000000..b7832118
--- /dev/null
+++ b/kdejava/koala/test/kmenu/KdeMenuSample.java
@@ -0,0 +1,142 @@
+/*
+ * KdeMenuSample.java
+ *
+ * Created on 8. Marz 2002, 20:31
+ */
+
+//package com.werpu.sample3;
+
+//import com.werpu.common.*;
+import org.kde.koala.kdejava;
+import org.kde.qt.qtjava;
+
+import org.kde.koala.KMainWindow;
+import org.kde.koala.KCmdLineArgs;
+import org.kde.qt.QPopupMenu;
+import org.kde.qt.QTextView;
+import org.kde.koala.KMenuBar;
+import org.kde.koala.KApplication;
+import org.kde.koala.KURL;
+import org.kde.koala.KFileDialog;
+import org.kde.koala.KMessageBox;
+import org.kde.qt.QColor;
+import org.kde.qt.QButton;
+import org.kde.koala.KPushButton;
+
+
+
+/**
+ * @author Werner Punz werpu@gmx.at
+ * To Java translated KDE Menu Example from
+ * The kde.org KDE Tutorial from Antonio Larrosa Jimenez
+ * http://person.wanadoo.es/antlarr/tutorial
+ */
+public class KdeMenuSample extends KMainWindow {
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+ KApplication kApp = null;
+
+ /** Creates a new instance of KdeMenuSample */
+ public KdeMenuSample(KApplication kApp) {
+ super(null,"Menu Sample",1);
+ this.kApp = kApp;
+ setCaption("KDE3 Tutorial");
+ createMenu();
+ QTextView centralWidget = createTextView();
+
+ this.setCentralWidget(centralWidget);
+ }
+
+
+ /**
+ * creates the file menu
+ */
+ private QPopupMenu createFileMenu() {
+ QPopupMenu fileMenu = new QPopupMenu(this);
+ fileMenu.insertItem("&Open",this,this.SLOT("fileOpen()"));
+ fileMenu.insertItem("&Save",this,this.SLOT("fileSave()"));
+ fileMenu.insertItem("&Quit",kApp,kApp.SLOT("quit()"));
+ return fileMenu;
+ }
+
+ /**
+ * creates the about menu
+ */
+ private QPopupMenu createAboutMenu() {
+ StringBuffer aboutText = new StringBuffer();
+
+ aboutText.append("Menu Example: \n ");
+ aboutText.append("Originally written by Antonio Larrosa Jimenez larossa@kde.org \n");
+ aboutText.append("Translated to Java by Werner Punz werpu@gmx.at \n");
+ aboutText.append("Simple KDE Tutorial\n");
+ aboutText.append("This tutorial comes with ABSOLUTELY NO WARRANTY\n");
+ aboutText.append("This is free software, and you are welcome to redistribute it\n");
+ aboutText.append("under certain conditions\n");
+
+ QPopupMenu aboutMenu = helpMenu(aboutText.toString(),true);
+
+ return aboutMenu;
+ }
+
+ /**
+ * creates the menu
+ */
+ private void createMenu() {
+ KMenuBar mainMenu = kmenuBar();
+ mainMenu.insertItem("&File",createFileMenu());
+ mainMenu.insertSeparator();
+ mainMenu.insertItem("&About",createAboutMenu());
+ }
+
+ /**
+ * creates the textview of the window
+ */
+ private QTextView createTextView() {
+ StringBuffer textBuf = new StringBuffer();
+ textBuf.append("<H2>Hello World !</H2><BR>This is a simple");
+ textBuf.append(" window with <I><font size=5><B>R<font color=red");
+ textBuf.append(" size=5>ich </font><font color=blue size=5>Text");
+ textBuf.append("</font></B></I> capabilities<BR>Try to resize");
+ textBuf.append(" this window, all this is automatic !</H2>");
+
+ QTextView mainTextView = new QTextView(this,"");
+ mainTextView.setText(textBuf.toString());
+
+
+ return mainTextView;
+ }
+
+ //--------------------------------------------------------------
+ //Slots
+ //--------------------------------------------------------------
+ public void fileOpen() {
+ //System.out.println("File Open");
+ KURL filename = KFileDialog.getOpenURL("", "*", this,"Open File" );
+ String msg = "Now this app should open the url " + filename.url();
+ KMessageBox.information(this , msg, "Information" , "fileOpenInformationDialog" );
+ }
+
+ public void fileSave() {
+ KURL filename = KFileDialog.getSaveURL( "" , "*", this, "Save File" );
+ }
+
+ //----------------------------------------------------------------
+ // main method
+ //----------------------------------------------------------------
+ public static void main(String [] argv) {
+ KCmdLineArgs.init(argv, "menuapp", "MenuApp",
+ "A simple menu example", "0.1");
+ KApplication menuApp = new KApplication();
+ KdeMenuSample mainWnd = new KdeMenuSample(menuApp);
+
+ mainWnd.resize(100,300);
+ menuApp.setMainWidget(mainWnd);
+
+ mainWnd.show();
+ menuApp.exec();
+ }
+}