導航:首頁 > 編程語言 > javajframe列表

javajframe列表

發布時間:2023-06-09 21:18:25

A. java 中 jFrame是什麼 怎麼用 具體

JPanel包含於復JFrame之中 Container是容器 包含制所有組建的類 一般開發你可以不考慮Container 直接在JFrame上操作 要用可以通過方法 好像是getContainer()(具體自己查下API 反正我沒怎麼用到過) 一個JFrame可以包...

B. 如何向java jframe中添加下拉列表 按鈕 文本框 最後把信息存儲在文件

lz 你好

(ps: lz 加點兒分吧 太少了……)


具體代碼如下:

importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.io.*;


publicclassTestextendsJFrame{
privateJLabelname,phone,sex;
privateJTextFieldinputName,inputPhone;
privateJComboBoxsexBox;
privateString[]item={"男","女"};
privateJButtonsave;

publicTest(){
super("信息管理");
setSize(240,300);
setLayout(newFlowLayout(FlowLayout.CENTER,10,30));

name=newJLabel("姓名:");
phone=newJLabel("手機號:");
sex=newJLabel("性別:");

inputName=newJTextField(14);
inputPhone=newJTextField(14);

sexBox=newJComboBox(item);

save=newJButton("儲存");
save.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(inputName.getText().equals("")||inputPhone.getText().equals("")){
return;
}

try{
Filef=newFile("info.txt");
BufferedWriterbw=newBufferedWriter(newFileWriter(f,true));

if(f.length()==0){
bw.write("姓名 性別 手機號");
bw.newLine();
}

Stringstr=inputName.getText()+" "+sexBox.getSelectedItem()+" "+inputPhone.getText();
bw.write(str);
bw.newLine();
bw.close();
}catch(Exceptionex){
}
}
});

getContentPane().setBackground(Color.WHITE);
getContentPane().add(Box.createHorizontalStrut(5));
getContentPane().add(name);
getContentPane().add(inputName);
getContentPane().add(phone);
getContentPane().add(inputPhone);
getContentPane().add(Box.createHorizontalStrut(35));
getContentPane().add(sex);
getContentPane().add(sexBox);
getContentPane().add(Box.createHorizontalStrut(35));
getContentPane().add(save);

setLocationRelativeTo(null);
setVisible(true);
setDefaultCloseOperation(3);
}

publicstaticvoidmain(String[]args){
newTest();
}
}



希望能幫助你哈

C. java-JFrame

在你需要new這個窗體的地方寫入如下代碼:
Frame1 fram = new Frame1();//創建Frame1實例
fram.setLocationRelativeTo(this);//設置Frame1相對於指定組件的位置
fram.setVisible(true);//設置此組件是否可見
fram.setResizable(false);//禁止窗體最大化,也不能調整尺寸。
this.dispose();//銷毀當前窗口

這幾個都是顯示/銷毀窗體常用的方法,需要哪個用哪個吧.

D. java中的JFrame

/**
* 這是可運行復的例子
*/

import javax.swing.JFrame;
public class TestFrame extends JFrame{

/**
* 構造方法
*/
public TestFrame() {
this.setVisible(true);//設置窗體可見.
this.setSize(300,300);//設置大小.

//----你應該是少了這句代碼
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//設置關閉動作.就是點擊 x 按鈕,退出程序
}

public static void main(String[] args) {
new TestFrame();
}

}

E. 關於 java JFrame類中的方法!!!

EXIT_ON_CLOSE是JFrame類的一個靜態的公有屬性
所以要用JFrame.EXIT_ON_CLOSE取得,當然用frame.EXIT_ON_CLOSE也不會有錯,但是不符合Java規范

如果是在類A裡面用的話,因為A是繼承了JFrame的,所以可以直接用父類中的EXIT_ON_CLOSE
就是setDefaultCloseOperation(EXIT_ON_CLOSE);

你的情況是在A類外面調用,所以只能用setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

F. JAVA中JFrame有什麼語法

JFrame自己的API有很多,其API數目太多了。如下:
protected void addImpl(Component comp, Object constraints, int index)
添加指定的子 Component。
protected JRootPane createRootPane()
由構造方法調用,以創建默認的 rootPane。
protected void frameInit()
由構造方法調用,以適當地初始化 JFrame。
AccessibleContext getAccessibleContext()
獲得與此 JFrame 關聯的 AccessibleContext。
Container getContentPane()
返回此窗體的 contentPane 對象
int getDefaultCloseOperation()
返回用戶在此窗體上發起 "close" 時執行的操作。
Component getGlassPane()
返回此窗體的 glassPane 對象。
JMenuBar getJMenuBar()
返回此窗體上設置的菜單欄。
JLayeredPane getLayeredPane()
返回此窗體的 layeredPane 對象。
JRootPane getRootPane()
返回此窗體的 rootPane 對象。
static boolean isDefaultLookAndFeelDecorated()
如果新創建的 JFrame 應該由當前外觀為其提供 Window 裝飾,則返回 true。
protected boolean isRootPaneCheckingEnabled()
返回是否將對 add 和 setLayout 的調用轉發到 contentPane。
protected String paramString()
返回此 JFrame 的字元串表示形式。
protected void processWindowEvent(WindowEvent e)
處理此組件上發生的窗口事件。
void remove(Component comp)
從該容器中移除指定組件。
void setContentPane(Container contentPane)
設置 contentPane 屬性。
void setDefaultCloseOperation(int operation)
設置用戶在此窗體上發起 "close" 時默認執行的操作。
static void (boolean defaultLookAndFeelDecorated)
提供一個關於新創建的 JFrame 是否應該具有當前外觀為其提供的 Window 裝飾(如邊框、關閉窗口的小部件、標題等等)的提示。
void setGlassPane(Component glassPane)
設置 glassPane 屬性。
void setIconImage(Image image)
設置此 frame 要顯示在最小化圖標中的圖像。
void setJMenuBar(JMenuBar menubar)
設置此窗體的菜單欄。
void setLayeredPane(JLayeredPane layeredPane)
設置 layeredPane 屬性。
void setLayout(LayoutManager manager)
設置 LayoutManager。
protected void setRootPane(JRootPane root)
設置 rootPane 屬性。
protected void setRootPaneCheckingEnabled(boolean enabled)
設置是否將對 add 和 setLayout 的調用轉發到 contentPane。
void update(Graphics g)
只是調用 paint(g)。

它是Frame的子類,所以它的大部分功能來源於Frame的功能。如下:
void addNotify()
通過將此 Frame 連接到本機屏幕資源,從而使其成為可顯示的。
protected void finalize()
移除輸入方法和上下文,並從 AppContext 中移除此 Frame。
AccessibleContext getAccessibleContext()
獲取與此 Frame 有關的 AccessibleContext。
int getCursorType()
已過時。 從 JDK version 1.1 開始,由 Component.getCursor() 取代。
int getExtendedState()
獲取此 frame 的狀態。
static Frame[] getFrames()
返回一個數組,包含由應用程序創建的所有 Frame。
Image getIconImage()
獲取此 frame 顯示在最小化圖標中的圖像。
Rectangle getMaximizedBounds()
獲取此 frame 的最大化邊界。
MenuBar getMenuBar()
獲取此 frame 的菜單欄。
int getState()
獲取此 frame 的狀態(已廢棄)。
String getTitle()
獲得 frame 的標題。
boolean isResizable()
指示此 frame 是否可由用戶調整大小。
boolean isUndecorated()
指示此 frame 是否未裝飾。
protected String paramString()
返回表示此 Frame 狀態的字元串。
void remove(MenuComponent m)
從此 frame 移除指定的菜單欄。
void removeNotify()
通過移除與本機屏幕資源的連接,將此 Frame 設置為不可顯示的。
void setCursor(int cursorType)
已過時。 從 JDK version 1.1 開始,由 Component.setCursor(Cursor) 取代。
void setExtendedState(int state)
設置此 frame 的狀態。
void setIconImage(Image image)
設置此 frame 要顯示在最小化圖標中的圖像。
void setMaximizedBounds(Rectangle bounds)
設置此 frame 的最大化邊界。
void setMenuBar(MenuBar mb)
將此 frame 的菜單欄設置為指定的菜單欄。
void setResizable(boolean resizable)
設置此 frame 是否可由用戶調整大小。
void setState(int state)
設置此 frame 的狀態(已廢棄)。
void setTitle(String title)
將此 frame 的標題設置為指定的字元串。
void setUndecorated(boolean undecorated)
禁用或啟用此 frame 的裝飾。
此外,由於Frame繼承了java.awt.Window類,所以也具有該類的功能,如下:
void addNotify()
通過創建到其本機屏幕資源的連接,使此窗口變得可顯示。
void addPropertyChangeListener(PropertyChangeListener listener)
將 PropertyChangeListener 添加到偵聽器列表。
void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
將 PropertyChangeListener 添加到某個特定屬性的偵聽器列表。
void addWindowFocusListener(WindowFocusListener l)
添加指定的窗口焦點偵聽器,以從此窗口接收窗口事件。
void addWindowListener(WindowListener l)
添加指定的窗口偵聽器,以從此窗口接收窗口事件。
void addWindowStateListener(WindowStateListener l)
添加指定的窗口狀態偵聽器,以從此窗口接收窗口事件。
void applyResourceBundle(ResourceBundle rb)
已過時。 從 J2SE 1.4 開始,由 Component.applyComponentOrientation 取代。
void applyResourceBundle(String rbName)
已過時。 從 J2SE 1.4 開始,由 Component.applyComponentOrientation 取代。
void createBufferStrategy(int numBuffers)
為此組件上的多緩沖創建一個新策略。
void createBufferStrategy(int numBuffers, BufferCapabilities caps)
根據所需緩沖功能為此組件上的多緩沖創建新策略。
void dispose()
釋放由此 Window、其子組件及其擁有的所有子組件所使用的所有本機屏幕資源。
protected void finalize()
釋放輸入方法和上下文,並從 GUI 層次結構中移除此 Window。
AccessibleContext getAccessibleContext()
獲取與此窗口關聯的 AccessibleContext。
BufferStrategy getBufferStrategy()

boolean getFocusableWindowState()
返回如果此窗口滿足 isFocusableWindow 中列出的其他要求,其是否可以成為焦點窗口。
Container getFocusCycleRootAncestor()
始終返回 null,原因是窗口沒有祖先;它們表示組件層次結構的頂層。
Component getFocusOwner()
如果此窗口為焦點窗口,則返回其具有焦點窗口的子組件;否則返回 null。
Set<AWTKeyStroke> getFocusTraversalKeys(int id)
獲取此窗口的焦點遍歷鍵。
GraphicsConfiguration getGraphicsConfiguration()
此方法返回由此窗口使用的 GraphicsConfiguration。
InputContext getInputContext()
獲取此窗口的輸入上下文。
<T extends EventListener>
T[]
getListeners(Class<T> listenerType)
返回當前在此 Window 上注冊為 FooListener 的所有對象的數組。
Locale getLocale()
如果設置了區域,則獲取與此窗口關聯的 Locale 對象。
Component getMostRecentFocusOwner()
返回此窗口的子組件,該子組件在此窗口為焦點窗口時將接收焦點。
Window[] getOwnedWindows()
返回包含此窗口當前擁有的所有窗口的數組。
Window getOwner()
返回此窗口的所有者。
Toolkit getToolkit()
返回此框架的工具包。
String getWarningString()
獲取此窗口中顯示的警告字元串。
WindowFocusListener[] getWindowFocusListeners()
返回在此窗口注冊的所有窗口焦點偵聽器的數組。
WindowListener[] getWindowListeners()
返回在此窗口注冊的所有窗口偵聽器的數組。
WindowStateListener[] getWindowStateListeners()
返回在此窗口注冊的所有窗口狀態偵聽器的數組。
void hide()
已過時。 從 JDK 5 開始,由 Component.setVisible(boolean) 取代。
boolean isActive()
返回此窗口是否為活動窗口。
boolean isAlwaysOnTop()
返回此窗口是否為 always-on-top 窗口。
boolean isFocusableWindow()
返回此窗口是否可以成為焦點窗口,也就是說,此窗口或其任何子組件是否可以成為焦點所有者。
boolean isFocusCycleRoot()
始終返回 true,原因是所有窗口必須為焦點遍歷循環的根。
boolean isFocused()
返回此窗口是否為焦點窗口。
boolean isLocationByPlatform()
如果在此窗口下次可見時,顯示在本機窗口操作系統的默認位置,則返回 true。
boolean isShowing()
檢查此窗口是否顯示在屏幕上。
void pack()
調整此窗口的大小,以適合其子組件的首選大小和布局。
boolean postEvent(Event e)
已過時。 從 JDK version 1.1 開始,由 dispatchEvent(AWTEvent) 取代。
protected void processEvent(AWTEvent e)
處理此窗口上的事件。
protected void processWindowEvent(WindowEvent e)
處理此窗口上發生的窗口事件,方法是將它們調度到任何注冊的 WindowListener 對象。
protected void processWindowFocusEvent(WindowEvent e)
處理此窗口上發生的窗口焦點事件,方法是將它們調度到任何注冊的 WindowFocusListener 對象。
protected void processWindowStateEvent(WindowEvent e)
處理此窗口上發生的窗口狀態事件,方法是將它們調度到任何注冊的 WindowStateListener 對象。
void removeWindowFocusListener(WindowFocusListener l)
移除指定的窗口焦點偵聽器,以便不再從此窗口接收窗口事件。
void removeWindowListener(WindowListener l)
移除指定的窗口偵聽器,以便不再從此窗口接收窗口事件。
void removeWindowStateListener(WindowStateListener l)
移除指定的窗口狀態偵聽器,以便不再從此窗口接收窗口事件。
void setAlwaysOnTop(boolean alwaysOnTop)
更改始終位於頂層的窗口狀態。
void setBounds(int x, int y, int width, int height)
重繪組件的指定矩形區域。
void setCursor(Cursor cursor)
設置指定游標的游標圖像。
void setFocusableWindowState(boolean focusableWindowState)
設置如果此窗口滿足 isFocusableWindow 中列出的其他要求,其是否可以成為焦點窗口。
void setFocusCycleRoot(boolean focusCycleRoot)
不執行任何操作,原因是窗口必須始終為焦點遍歷循環的根。
void setLocationByPlatform(boolean locationByPlatform)
設置在下次窗口可見時,此窗口是應顯示在本機窗口系統的默認位置,還是應顯示在當前位置(由 getLocation 返回)。
void setLocationRelativeTo(Component c)
設置此窗口相對於指定組件的位置。
void show()
已過時。 從 JDK 5 開始,由 Component.setVisible(boolean) 取代。
void toBack()
如果此窗口是可視的,則將此窗口發送到後台,如果它是焦點窗口或活動窗口,則會導致丟失焦點或激活狀態。
void toFront()
如果此窗口是可見的,則將此窗口置於前端,並可以將其設為焦點窗口。

閱讀全文

與javajframe列表相關的資料

熱點內容
dede工具 瀏覽:507
5g網盟app怎麼下載 瀏覽:486
微信備份老是連接中斷 瀏覽:886
出台多少份文件 瀏覽:380
鞋子怎麼搭配衣服的app 瀏覽:755
文件名使用的通配符的符號是什麼 瀏覽:916
lol分卷文件損壞怎麼辦 瀏覽:276
6分管車螺紋怎麼編程 瀏覽:732
海口農商銀行信用卡app是什麼 瀏覽:770
win10任務欄文件夾我的電腦 瀏覽:14
安卓nba2k18 瀏覽:776
文件夾密碼怎麼修改密碼 瀏覽:271
蘋果數據中心用什麼伺服器 瀏覽:769
省內圓通快遞寄文件夾需要多少錢 瀏覽:740
iphone程序加密 瀏覽:884
win10文件夾調整文件行高 瀏覽:681
創意手繪教程 瀏覽:754
微信刪除帳號信息 瀏覽:596
mysql操作類文件 瀏覽:649
繞過xp密碼 瀏覽:158

友情鏈接