如何更改按钮单击时的边框标题? [英] How to change border title on button click?

查看:39
本文介绍了如何更改按钮单击时的边框标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个 GUI 界面.我制作了标题为员工详细信息"的包装面板,如下面的屏幕截图所示:

I am trying to build a GUI interface. I have made wrapper panel which has the title "Staff Details" as in the screenshot below:

我用下面的代码在边框上设置标题

I used the following code to set the title on the border

wrapper.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Staff Details",TitledBorder.CENTER, TitledBorder.TOP));

现在我想在单击查看"按钮时将标题更改为查看详细信息".我该怎么做?

Now I want to change the title to "View Details" when I click the "View" button. How do I do that?

推荐答案

大概保留 TitledBorder 参考

TitledBorder titledBorder = BorderFactory.createTitledBorder(...);

那么你应该可以 setTitle()

titledBorder.setTitle("New Title");
repaint();

这篇关于如何更改按钮单击时的边框标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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