简体   繁体   English

更改Java JFrame的图块

[英]Changing the tile of a java JFrame

I'm wondering, how can I set the title of my Java JFrame GUI to something different later on? 我想知道,以后如何将Java JFrame GUI的标题设置为其他名称? My program is a basic text editor, and I want to change the title to whatever you just saved your file as, or New File if you hit the New File button, or you just started the application up. 我的程序是一个基本的文本编辑器,我想将标题更改为您刚刚将文件另存为的名称,如果单击“新建文件”按钮,或者刚启动应用程序,则将其更改为“新建文件”。 The method I'm using right now is just a simple setName("" + file + ""); 我现在使用的方法只是一个简单的setName("" + file + ""); where file is the File that was just written or read. 其中file是刚刚写入或读取的文件。

setTitle是您需要的,而不是setName。

您可以使用Frame#setTitle(String)设置JFrame的标题。

yourJFrame.setTitle("words.txt");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM