gpt4 book ai didi

java - 单击按钮时禁用 JTextPane 上的编辑 (Java)

转载 作者:行者123 更新时间:2023-12-01 19:28:27 25 4
gpt4 key购买 nike

好的,所以我正在制作一个简单的程序,根据单击的相应按钮将编辑 JTextPane 的能力设置为 true 或 false。但是,我不知道如何禁用和重新启用编辑- Pane 的能力。 JTextPane 这是我正在努力解决的代码:

`JTextPane Pad1 = new JTextPane();
Pad1.setText("Edit Me...");
Pad1.setBounds(10, 45, 188, 160);
frmDuvalStudiosOffscreen.getContentPane().add(Pad1);


JButton button = new JButton("Save");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//I want to make it when this button is clicked, it sets the ability to edit Pad1 to false.
}
});
button.setBounds(10, 239, 89, 23);
frmDuvalStudiosOffscreen.getContentPane().add(button);

JButton button_1 = new JButton("Edit");
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//I want to make it when this button is clicked, it sets the ability to edit Pad1 to true.
}
});'

请提供代码和文本。谢谢!

最佳答案

有两种方法:

Sets the specified boolean to indicate whether or not this TextComponent should be editable.

Sets whether or not this component is enabled. A component that is enabled may respond to user input, while a component that is not enabled cannot respond to user input

关于java - 单击按钮时禁用 JTextPane 上的编辑 (Java),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60644828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com