Panel not getting focus

The Panel class was designed as container, it avoids taking the focus so a child control will always get it. You’ll need some surgery to fix that. I threw in the code to get cursor key strokes in the KeyDown event as well: using System; using System.Drawing; using System.Windows.Forms; class SelectablePanel : Panel { public … Read more

How Do I Use KeyEventDispatcher

you have to look for KeyBindings import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.*; import java.util.HashMap; import java.util.Map; import javax.imageio.ImageIO; import javax.swing.*; public class MoveIcon extends JPanel { private static final long serialVersionUID = 1L; private static final String IMAGE_PATH = “http://duke.kenai.com/misc/Bullfight.jpg”; private static final String IMAGE_PATH_PLAYER = “http://duke.kenai.com/iconSized/duke4.gif”; public static final int … Read more

How do I detect if software keyboard is visible on Android Device or not?

This works for me. Maybe this is always the best way for all versions. It would be effective to make a property of keyboard visibility and observe this changes delayed because the onGlobalLayout method calls many times. Also it is good to check the device rotation and windowSoftInputMode is not adjustNothing. boolean isKeyboardShowing = false; … Read more

Android: How do I prevent the soft keyboard from pushing my view up?

You can simply switch your Activity’s windowSoftInputModeflag to adjustPan in your AndroidMainfest.xml file inside your activity tag. Check the official documentation for more info. <activity … android:windowSoftInputMode=”adjustPan”> </activity> If your container is not changing size, then you likely have the height set to “match parent”. If possible, set the parent to “Wrap Content”, or a … Read more

How to handle events from keyboard and mouse in full screen exclusive mode in java?

It looks like the usual approaches shown in How to Use Key Bindings and How to Write a Mouse Listener work correctly in Full-Screen Exclusive Mode. import java.awt.Color; import java.awt.EventQueue; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowEvent; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import … Read more