我有一个案文领域,在进入纽顿时,我想变成空白。 我知道,这样做通常会采用一套办法。 然而,当我这样做时,案文被删除,但返回钥匙所产生的新的线功能却受到压力。 我的问题是,阻止这一缺席行动发生是否有任何途径?
感谢
我有一个案文领域,在进入纽顿时,我想变成空白。 我知道,这样做通常会采用一套办法。 然而,当我这样做时,案文被删除,但返回钥匙所产生的新的线功能却受到压力。 我的问题是,阻止这一缺席行动发生是否有任何途径?
感谢
你们是否聆听了环境词汇在文字领域的关键,然后予以清除? 以下是我的工作:
final JTextArea ta = new JTextArea();
ta.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER){
ta.setText("");
}
}
@Override
public void keyPressed(KeyEvent e) {
}
});
希 腊
我有一个案文领域,在进入纽顿时,我想变成空白。
我理解这一点。 在这方面,你可以做些什么:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main {
public static void main(String[]args) {
final JFrame frame = new JFrame();
final JTextArea area = new JTextArea();
area.setPreferredSize(new Dimension(200, 200));
area.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER) {
area.setText("");
}
}
});
frame.add(area);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
我知道,这样做通常会采用一套办法。 然而,当我这样做时,案文被删除,但返回钥匙所产生的新的线功能却受到压力。 我的问题是,阻止这一缺席行动发生是否有任何途径?
我对此不理解。
问题很可能是,你不会消耗关键的中风事件,尽管案文区已经清除,但关键中风的正常处理最终会插入一条新线。
我建议使用文件Filter,而不是绕过关键的中风事件(它必然是便携式的)。 http://www.java2s.com/Code/Java/Swing-JFC/DocumentFilter:mapsdowncaseletterstouppercase.htm“rel=“nofollow noreferer”> 。 执行过滤器,以便在插入或替换插图时,用“”取代文件的全部内容。
然而,这种办法可以说明在关键板上打上新线与在案文区打上新线之间的区别。
在你澄清案文之前,你需要删除返回纽顿所遗留的新路线。 页: 1
您的案文:
yourkeyevent.consume();
yourTextObject.setText("");
相反,你也可以使用:
yourTextarea.setText(null);
yourTextarea.setCaretPosition(-1);
I solved your problem overriding the code in the method "public void keyTyped(KeyEvent e)" instead of "public void keyPressed(KeyEvent e)" and it works. Here the code:
package versione1;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class WhiteEnter {
final JFrame frame = new JFrame();
private JTextArea area = new JTextArea();
public static void main(String[]args) {
WhiteEnter prova = new WhiteEnter();
prova.run();
}
public void run(){
area.setPreferredSize(new Dimension(200, 200));
area.addKeyListener(new PressEnterKeyListener());
frame.add(area);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public class PressEnterKeyListener implements KeyListener{
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyTyped(KeyEvent e) {
if (e.getKeyChar() == (KeyEvent.VK_ENTER)){
try{
area.setText(null);
area.setCaretPosition(0);
} catch(Exception ex){
ex.printStackTrace();
}
}
}
}
}
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...