你如何获得 JFrame 标题的值? [英] How do you get the value of the JFrame title?

查看:47
本文介绍了你如何获得 JFrame 标题的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够从 JFrame 获取字符串.这是因为 JFrame 的标题不是常量,而是依赖于变量.

I want to be able to get the string from the JFrame. This is because the title of the JFrame is not constant and is dependent on variables.

有没有办法将标题的文本分配给字符串变量?

Is there a way to assign to a string variable the text of the title?

    private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
    if(super.checkifEmptyFields(jPanel3)==false){
        String LeaseName = jTextField2.getText().toLowerCase();
        String sld[]  =jDateChooser1.getDate().toString().split(" ");
        String startLeasingDate = sld[0]+","+sld[1]+","+sld[5].toLowerCase();
        String eld[]  =jDateChooser1.getDate().toString().split(" ");
        String EndLeasingDate = eld[0]+","+eld[1]+","+eld[5].toLowerCase();
        String leaseAmount = jTextField3.getText();
        String text = jTextField1.getText();
        int floor = Integer.parseInt(text.substring(6, 7));
        int flat = Integer.parseInt(text.substring(13));
        //String name NewLease2.getTitle;
    }
}

类名为 NewLease2,这是我想要在用户按下按钮时执行的功能.

The class name is called NewLease2 and this is the function I want to perform when the user presses a button.

推荐答案

为什么不试试:

JFrame j = new JFrame("My Title here");
String whatTitle = j.getTitle();

这篇关于你如何获得 JFrame 标题的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆