You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
4.5 KiB
143 lines
4.5 KiB
15 years ago
|
/*
|
||
|
* KdeMenuSample.java
|
||
|
*
|
||
|
* Created on 8. Marz 2002, 20:31
|
||
|
*/
|
||
|
|
||
|
//package com.werpu.sample3;
|
||
|
|
||
|
//import com.werpu.common.*;
|
||
11 years ago
|
import org.trinitydesktop.koala.tdejava;
|
||
|
import org.trinitydesktop.qt.qtjava;
|
||
15 years ago
|
|
||
11 years ago
|
import org.trinitydesktop.koala.TDEMainWindow;
|
||
|
import org.trinitydesktop.koala.TDECmdLineArgs;
|
||
|
import org.trinitydesktop.qt.TQPopupMenu;
|
||
|
import org.trinitydesktop.qt.TQTextView;
|
||
|
import org.trinitydesktop.koala.KMenuBar;
|
||
|
import org.trinitydesktop.koala.TDEApplication;
|
||
|
import org.trinitydesktop.koala.KURL;
|
||
|
import org.trinitydesktop.koala.KFileDialog;
|
||
|
import org.trinitydesktop.koala.KMessageBox;
|
||
|
import org.trinitydesktop.qt.TQColor;
|
||
|
import org.trinitydesktop.qt.TQButton;
|
||
|
import org.trinitydesktop.koala.KPushButton;
|
||
15 years ago
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @author Werner Punz werpu@gmx.at
|
||
|
* To Java translated KDE Menu Example from
|
||
11 years ago
|
* The kde.org KDE Tutorial from Antonio Larrosa Jimenez
|
||
15 years ago
|
* http://person.wanadoo.es/antlarr/tutorial
|
||
|
*/
|
||
12 years ago
|
public class KdeMenuSample extends TDEMainWindow {
|
||
11 years ago
|
|
||
15 years ago
|
static {
|
||
|
qtjava.initialize();
|
||
11 years ago
|
tdejava.initialize();
|
||
15 years ago
|
}
|
||
11 years ago
|
|
||
12 years ago
|
TDEApplication kApp = null;
|
||
15 years ago
|
|
||
|
/** Creates a new instance of KdeMenuSample */
|
||
12 years ago
|
public KdeMenuSample(TDEApplication kApp) {
|
||
15 years ago
|
super(null,"Menu Sample",1);
|
||
|
this.kApp = kApp;
|
||
13 years ago
|
setCaption("TDE Tutorial");
|
||
15 years ago
|
createMenu();
|
||
13 years ago
|
TQTextView centralWidget = createTextView();
|
||
11 years ago
|
|
||
15 years ago
|
this.setCentralWidget(centralWidget);
|
||
|
}
|
||
11 years ago
|
|
||
|
|
||
15 years ago
|
/**
|
||
|
* creates the file menu
|
||
|
*/
|
||
13 years ago
|
private TQPopupMenu createFileMenu() {
|
||
|
TQPopupMenu fileMenu = new TQPopupMenu(this);
|
||
15 years ago
|
fileMenu.insertItem("&Open",this,this.SLOT("fileOpen()"));
|
||
|
fileMenu.insertItem("&Save",this,this.SLOT("fileSave()"));
|
||
|
fileMenu.insertItem("&Quit",kApp,kApp.SLOT("quit()"));
|
||
|
return fileMenu;
|
||
|
}
|
||
11 years ago
|
|
||
15 years ago
|
/**
|
||
|
* creates the about menu
|
||
|
*/
|
||
13 years ago
|
private TQPopupMenu createAboutMenu() {
|
||
15 years ago
|
StringBuffer aboutText = new StringBuffer();
|
||
11 years ago
|
|
||
15 years ago
|
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");
|
||
13 years ago
|
aboutText.append("Simple TDE Tutorial\n");
|
||
15 years ago
|
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");
|
||
11 years ago
|
|
||
13 years ago
|
TQPopupMenu aboutMenu = helpMenu(aboutText.toString(),true);
|
||
11 years ago
|
|
||
15 years ago
|
return aboutMenu;
|
||
|
}
|
||
11 years ago
|
|
||
15 years ago
|
/**
|
||
|
* creates the menu
|
||
|
*/
|
||
|
private void createMenu() {
|
||
|
KMenuBar mainMenu = kmenuBar();
|
||
|
mainMenu.insertItem("&File",createFileMenu());
|
||
|
mainMenu.insertSeparator();
|
||
|
mainMenu.insertItem("&About",createAboutMenu());
|
||
|
}
|
||
11 years ago
|
|
||
15 years ago
|
/**
|
||
|
* creates the textview of the window
|
||
|
*/
|
||
13 years ago
|
private TQTextView createTextView() {
|
||
15 years ago
|
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>");
|
||
11 years ago
|
|
||
13 years ago
|
TQTextView mainTextView = new TQTextView(this,"");
|
||
15 years ago
|
mainTextView.setText(textBuf.toString());
|
||
11 years ago
|
|
||
|
|
||
15 years ago
|
return mainTextView;
|
||
|
}
|
||
11 years ago
|
|
||
15 years ago
|
//--------------------------------------------------------------
|
||
|
//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" );
|
||
|
}
|
||
11 years ago
|
|
||
15 years ago
|
public void fileSave() {
|
||
|
KURL filename = KFileDialog.getSaveURL( "" , "*", this, "Save File" );
|
||
|
}
|
||
11 years ago
|
|
||
15 years ago
|
//----------------------------------------------------------------
|
||
|
// main method
|
||
|
//----------------------------------------------------------------
|
||
|
public static void main(String [] argv) {
|
||
12 years ago
|
TDECmdLineArgs.init(argv, "menuapp", "MenuApp",
|
||
15 years ago
|
"A simple menu example", "0.1");
|
||
12 years ago
|
TDEApplication menuApp = new TDEApplication();
|
||
15 years ago
|
KdeMenuSample mainWnd = new KdeMenuSample(menuApp);
|
||
11 years ago
|
|
||
15 years ago
|
mainWnd.resize(100,300);
|
||
|
menuApp.setMainWidget(mainWnd);
|
||
11 years ago
|
|
||
15 years ago
|
mainWnd.show();
|
||
|
menuApp.exec();
|
||
|
}
|
||
|
}
|