⑴ 要用java開發GUI,SWT,Jface,RCP有什麼聯系什麼關系。
jsf是表示層的框架,主要是web界面方面的應用;而其他的都屬於桌面UI庫,與前者不同,在此不做比較。
AWT是java早期版本使用的UI庫,為了跨平台,它指提供各個平台上支持的組件的最大公約數集合..比如蘋果操作系統並不支持按鈕的圖片展示,於是AWT的按鈕是無法使用圖片的;AWT的實現是以本機對等體的方式來實現的,即一個Button對象則對應於本機一個窗口組件(利用本地程序實現映射),於是AWT組件與本地組件長得是一模一樣的。
SWING則是基於AWT的基礎上做了許多擴展,它提供的是各種平台上支持的組件的最小公倍數集合..在設計上使用了MVC(分UI、Component、Model),除了窗口之外,其大部分組件都使用Java2D來實現渲染模擬,也因為如此,Swing在渲染方面的靈活性非常大。
SWT是IBM公司針對Java桌面UI開發出來的另一個分支,它的實現方式與AWT類似,都使用了本機對等體的實現,於是它的組件也與本機組件非常雷同;此外它遵循最小公倍數原則,對於非公共組件部分,它又使用了類似Draw2D庫的API來模擬渲染。JFace是SWT的增強包,它是對SWT的進一步封裝,使得SWT界面開發的模塊劃分更加清晰,代碼也更加維護。
綜上,在渲染的靈活性上面,swing是最優的,因為它的渲染可在java程序中實現(MVC),而AWT和SWT則因為本機對等體的緣故不是那麼靈活;在內存佔用上面,AWT和SWT比swing要少得多,而且也響應也要快一些,這是因為Swing將組件的渲染信息(甚至是像素信息)都放在程序內存中,並由自己管理,所以Swing界面響應很慢是不足為怪的~~;在支持的組件集合上,SWT和Swing比AWT豐富得多;最後,在穩定性上面,SWT稍顯不足~~
上面的幾種UI庫中,Swing和SWT都占據一定的份額吧,Swing在一些報表圖形展示方面有更好的靈活性,也有比較好的開源組件支持(如JFreeChart);而SWT在快速應用開發方面是非常合適的,Eclipse界面便是SWT的實現,而也基於此出現了Eclipse RCP技術(類似於MFC),該技術整合了SWT
⑵ java swt 登陸成功後,怎樣跳轉到主界面
樓主說詳細點吧!不明白你的意思!
⑶ java中SWT和swing是什麼關系在界面中分別扮演著什麼樣的角色
據我自己的使用情況來看:
awt使用起來較為繁瑣,但速度優於swing
⑷ JAVA SWT界面風格問題
用JAVA開發圖形界面是比較困難的,如果沒有一定的開發經驗,你恐怕很難去駕馭。
⑸ java SWT界面跳轉問題
dispose()
Disposes of the operating system resources associated with the receiver and all its descendents.第1個界面調用這個方法
⑹ JAVA用SWT寫的界面,怎樣把資料庫裡面的表顯示在SWT的table中並且實現修改查詢刪除功能。
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
public class TabViewTest {
public void open() throws Exception{
Display display=new Display();
Shell shell=new Shell(display);
shell.setLayout(new FillLayout());
shell.setSize(new Point(400,300));
Table table=new Table(shell,SWT.MULTI | SWT.FULL_SELECTION |SWT.BORDER);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn idColumn =new TableColumn(table,SWT.LEFT);
idColumn.setText("id");
idColumn.setWidth(100);
TableColumn usernameColumn=new TableColumn(table,SWT.LEFT);
usernameColumn.setText("username");
usernameColumn.setWidth(100);
TableColumn passwordColumn=new TableColumn(table,SWT.LEFT);
passwordColumn.setText("password");
passwordColumn.setWidth(100);
Connection conn=getAcessConnection();
String sqlString="select * from user";
Statement statement=conn.createStatement();
ResultSet rSet=statement.executeQuery(sqlString);
while(rSet.next()){
TableItem item=new TableItem(table,SWT.LEFT);
String[] valueStrings={rSet.getInt("id")+"0",rSet.getString("username"),rSet.getString("password")};
item.setText(valueStrings);
}
rSet.close();
statement.close();
conn.close();
shell.open();
while(!shell.isDisposed()){
if( !display.readAndDispatch()){
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) throws Exception {
new TabViewTest().open();
}
public Connection getAcessConnection(){
Connection conn=null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
URL url1=TabViewTest.class.getClassLoader().getResource("db/test.mdb");
String path=url1.getPath();
path=path.substring(1, path.length());
String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+path;
conn=DriverManager.getConnection(url);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
}
資料庫用的是access,樓主可以自己隨便修改下的。
⑺ java界面刷新SWT
SwingUtilities.updateComponentTreeUI (this);
用這個刷新即可