java開辟gui教程之jframe監聽窗體年夜小變更事宜和jframe創立窗體。本站提示廣大學習愛好者:(java開辟gui教程之jframe監聽窗體年夜小變更事宜和jframe創立窗體)文章只能為提供參考,不一定能成為您想要的結果。以下是java開辟gui教程之jframe監聽窗體年夜小變更事宜和jframe創立窗體正文
import java.awt.event.WindowEvent;
import java.awt.event.WindowStateListener;
import javax.swing.JFrame;
public class WinFrame extends JFrame {
public WinFrame(){
this.setName("Window 窗口狀況");
this.setSize(300,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.addWindowStateListener(new WindowStateListener () {
public void windowStateChanged(WindowEvent state) {
if(state.getNewState() == 1 || state.getNewState() == 7) {
System.out.println("窗口最小化");
}else if(state.getNewState() == 0) {
System.out.println("窗口恢復到初始狀況");
}else if(state.getNewState() == 6) {
System.out.println("窗口最年夜化");
}
}
});
this.setVisible(true);
}
public static void main(String[] args) {
new WinFrame();
}
}
別的一個應用JFrame創立窗體的小例子
應用JFrame創立的窗口分離包括一個題目、最小化按鈕、最年夜化按鈕和封閉按鈕
public class Test(){
public static void main(String[] args){
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JTextArea textArea = new JTextArea();
panel.setLayout(new GridLayout());
textArea.setText("test");
//當TextArea裡的內容太長時生成轉動條
panel.add(new JScrollPane(textArea));
frame.add(panel);
frame.setSize(200,200);
frame.setVisible(true);
}
}
示例
示例 1:
以下敕令在當地盤算機上啟用運用法式“Payroll”:
iisext /EnApp Payroll
作為呼應,iisext 顯示以下內容:
Connecting to server ...Done.
Enabling application complete.
示例 2:
以下敕令在長途盤算機上啟用運用法式“TravelPlans”:
iisext /EnApp TravelPlans /s RemoteComputer /u Manager /p Pa$$Werd
作為呼應,iisext 顯示以下內容:
Connecting to server ...Done.
Enabling application complete.