How to add KeyListener to JDialog
You can add KeyListener to your JDialog component as you can add it to any other swing components but when you add other components to JDialog, they eat key events.
To solve this problem you should register KeyboardAction for JDialog. In below code snippet typically I want sense F1 key pressing to do something:
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
};
KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0);
JRootPane rootPane = getRootPane();
rootPane.registerKeyboardAction(actionListener, keyStroke,JComponent.WHEN_IN_FOCUSED_WINDOW);
Force Swing componets to repaint
If n times repaint() method callings don’t refresh your your frame, use this one to force your Swing components to repaint!
Graphics g = getGraphics();
if (g != null) paintComponents(g);
else repaint();
Related thread on sun forum :
http://forum.java.sun.com/thread.jspa?threadID=497595
Java How to Program (6th Edition) (Deitel)
اگر میخواهید جاوا یاد بگیرید یا جاوا کار هستید و احساس می کنید گاهی با شک کد می زنید یا اینکه نیاز دارید بعضی چیزها را مرور کنیداین کتاب را بهتون پیشنهاد می کنم.

مفاهیم و جزئیات به مقدار لازم , ساده و روان با مثال های قابل درک و هزاران خط کد بیان شده. بخش های اولیه که بیشتر شامل مفاهیم برنامه نویسی شی گرا (Object Oriented Programming) و پیاده سازی آن در Java می شود کاملا مفید و کاربردی نوشته شده. مطالب کتاب با J2SE 1.5 کاملا هاهنگ و به روز می باشد, اگر در گذشته جاوا یاد گرفتید و هنوز بروز نشدید این کتاب میتواند منبع خوب و کاربردی ای برای شما باشد. نکته ی جالب دیگه اینکه اول هر فصل جملات قصاری از بزرگان حوضه های مختلف نوشته شده که به زیبائی به محتویات هر بخش مربوط می شود, از کنارشان به سادگی نگذرید.
این کتاب را می توانید از آمازون بخرید اما اگر شما هم مثل من ساکن همین خاک هستید غصه نخورید , می توانید از لینک زیر این کتاب را دانلود کنید!
دانلود
صفحه مربوط به این کتاب در آمازون
ضمنا سایت زیر یکی از کاملترین سایت های دانلود e-book های کامپیوتری و برنامه نویسی می باشد, اگر امکان خرید از آمازون را ندارید, از دنیا نباید عقب بمانید! دانلود کنید:
Flazx.Com
Deselect selected options by Javascript
To deselect selected option(s) of a Select tag in HTML you can use this JS code:
document.getElementById(selectTagId).selectedIndex = -1;selectTagId is Id of Select tag.
selectedIndex property is:
index of selected option,
it’s index of first selection in multi selection case,
starts from zero,
it’s ‘-1′ when no option is selected.
More about selectedIndex property and uses:
selectedIndex Property on MSDN
Working with selectedIndex
Ordering in java.util.HashMap
If you need ordering in your HashMap you should use LinkedHashMap.
More info from J2SE documentation:
Hash table and linked list implementation of the Map interface, with predictable iteration order. This implementation differs from HashMap in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is normally the order in which keys were inserted into the map (insertion-order).





