Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

non-understandable(Swing)  RSS feed

 
Vishal Mungi
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public void keyPressed(KeyEvent e) {
text = jtfTimeOut.getText();
// if (!terminal) {
try {
int value = Integer.parseInt(text);
System.out.println("Not teminal " + value);
if (value < 20) {
text = timeOutVal;
}
} catch (NumberFormatException nfe) {
nfe.printStackTrace();
text = timeOutVal;
}
if (e.getKeyChar() == KeyEvent.VK_UP) {
System.out.println("inside vk_up " + value);
value = Integer.parseInt(text);
if (value > 994 && value < 1000) {
value = 999;
} else {
value += ticks;
}
if (value > 999) {
value = Integer.parseInt(timeOutVal);
}
jtfTimeOut.setText("" + value);
} else if (e.getKeyChar() == KeyEvent.VK_DOWN) {
value = Integer.parseInt(text);
value -= ticks;
if (value < 20) {
value = 20;
}
jtfTimeOut.setText("" + value);
} else if (e.getKeyChar() == KeyEvent.VK_ENTER) {
System.out.println("ORIGINAL" + jtfTimeOut.getText());
System.out.println("Through jtf 1" + value);
if ((value < 20) || (value > 999)) {
value = Integer.parseInt(timeOutVal);
}
jtfTimeOut.setText("" + value);
System.out.println("Through jtf " + value);
sendQuote();
}
// }
}
});


this prints :

Not teminal 900 // original value

Not teminal 2 // as i start changing to 20

Not teminal 20 //for the 0

ORIGINAL20 // directly goes to enter ?

Through jtf 10

Through jtf 900
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's your question?

Please explain what you expect the output to be and how that is different from the actual output.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Swing forum.
 
Vishal Mungi
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually should'nt

Not teminal 20

be printed twice (once for 0 pressed & then for the enter) ?
 
Vishal Mungi
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
& sorry for the unformatted code ..
 
Vishal Mungi
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry again .. my mistake , 'value' has been declared twice
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!