Focus « Focus « Java Swing Q&A





1. In Swing, how can I find out what object currently has focus?    stackoverflow.com

I have few TextFields on my frame. I want to know the TextField name which is currently focused. Can someone please help me? How can I find out the current focused ...

2. Focus debugging in Java    stackoverflow.com

The problem:

I am trying to debug some focus-related problems in my Java Swing application. There are times when some components seem to be grabbing focus and I cannot figure out where ...

3. Java focus question    stackoverflow.com

This may be a silly question I don't know. Is there a way to remove the highlighter to represent focus in a Java GUI? For example when you click on a button ...

4. Swing- focus problem    stackoverflow.com

In my application I have a frame, with toolbar (the toolbar contains some actions). I want the toolbar to be visible only when the window is focused. So, I registered a windowFocusListener on ...

5. Java - How to set focus the already running application?    stackoverflow.com

I am using a ServerSocket port to run one instance only of my Java Swing application, so if a user tries to open another instance of the program, i show him ...

6. Swing: Steal focus from other apps (usability in OS X)    stackoverflow.com

I have an application in java swing which runs in the system tray most of the time. The user can use the Tray Menu to perform several actions. One of those ...

7. Swing - how to grab focus *now*?    stackoverflow.com

How can I instruct my Swing component to grab focus right now? requestFocus() doesn't seem to be dispatched instantly. Ideally, I would like this (ran from EDT):

textInput.requestFocusInWindow();
System.out.println(textInput.hasFocus());
To print true. Below is the SSCCE. ...

8. Java regression testing (with AWT involved) possible without stealing desktop focus?    stackoverflow.com

I've got regression tests of a Java system that don't bring up any graphical elements but do make use of the AWT event thread. Is there any way I can ...

9. java, swing, awt, remove focus from all objects    stackoverflow.com

I'm doing this project for school and for some reason one of by Buttons in one of my Panels has focus(i can change it with the tab button) Well whatever button ...





10. How to write a Java application who doesn't get the focus?    stackoverflow.com

Is it possible to write a Java application (Swing / JavaFX) who doesn't get the focus when launched? So that the application who had the focus before keeps it's focus?

11. Java Swing: Focus issue    stackoverflow.com

I'm making a level editor for my game. I have a property panel where I can modify the selected object its properties. I also have a Save button to write the ...

12. Focus owner temporary changes to null    stackoverflow.com

I'm pretty new to Swing development, hope my question is not a stupid one. I've got a following problem. I am tracking the focus using KeyboardFocusManager, listening for property permanentFocusOwner changes. However ...

13. setting focus......    coderanch.com

14. Question on focus    coderanch.com

15. Focus Traversable    coderanch.com

I know isFocusTraversable of Component returns the value of a flag that indicates whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal. But I don't know how to make certain component in my container to be not Tab Traversable or to be Tab Traversable. Is there any attribute on Component that I could set to achieve that? ...

16. Focus problems...    coderanch.com





17. Urgent focus issue    coderanch.com

Hi folks, I am having 2 windows,where the second window is launched by clicking the button on first window.If the second is minimised and if user tries to click the button on first window, the second which is already opened should get maximised. Basically how to maximise the window from its minised postion?? can anybody give the method which does?? thanks, ...

18. Focus issue    coderanch.com

19. focus problem    coderanch.com

20. Unable to retain focus    coderanch.com

21. Focus problem    coderanch.com

22. Focus    coderanch.com

Hi , i have created a login window with userid and password field in Swing. i validate these fields and pop up an error message. If an user leaves password field blank, a message window is displayed with message " please enter password".Now i want the following functionality to be achieved.On click of ok button in message window the focus should ...

23. how to set focus?    coderanch.com

24. Cut and Paste and Focus    coderanch.com

25. Focus - "blur" command?    coderanch.com

26. JPopup -> strange focus behaviour    coderanch.com

Hi, I'm trying to code a JTable that would react as follows: clicking a table header pops up a little filter component (a textfield + a combobox) under this header using a JPopup.Then, I'd like it to disappear when loosing the focus. So I added a FocusListener on the component embedded in the popup (it basically outputs the focus events and ...

27. Focus on load    coderanch.com

28. Gaining Focus    coderanch.com

29. JWindow & Focus    coderanch.com

30. Focus problem    coderanch.com

31. Where is a focus?    coderanch.com

32. Problems in Focus    coderanch.com

I have many and varied questions about focus management in java 1.4, if anyone could direct me to a great source of information on that subject I would appreciate it. One specific question I have has to do with KeyListeners. In 1.3 I was able to add a key listener to a JFrame which may have various other objects, lets say ...

33. wants to focusing on new added list item.. please help    coderanch.com

Here is a sample, which does what you need: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Vector; public class ListFrame extends JFrame { JScrollPane jScrollPane1 = new JScrollPane(); JList jList1 = new JList(); JToolBar jToolBar1 = new JToolBar(); JButton btnAdd = new JButton(); Vector listData = new Vector(); public ListFrame() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } ...

34. Is it a jdk1.4 focus problem, please help !!    coderanch.com

This is a feature, perhaps not completely thought out, rather than a bug. Java 1.4 changed quite a few details of focus cycle handling. The changes are pretty well documented if you start with the overview in the on-line docs: api/java/awt/doc-files/FocusSpec.html What you've run into is automatic focus transfer _from_ a component that's being disabled or hidden. This is an intentional ...

35. Focus traversal issue    coderanch.com

Hi, I am new to swing and am trying to understand how the new 1.4 focus framework works. Please help. I have a JPanel that contains 9 components (in order of addition JTextField hours, JTextField minutes, JTextField seconds, JRadioButton countUp, JRadioButton countDown, JButton start, JButton pause, JButton stop, JButton new). JButtons start, pause, stop and new are not active all the ...

36. Cursor positions / Focus    coderanch.com

I have a dialog window which demonstrates strange cursor behaviour. The last cursor position seems to be being remembered, so that when you open the dialog again you have two Cursor positions (only one of them is live though i.e. typing is only from one of them). You can close and re-open this time and again until you have a 'rogue' ...

37. SET FOCUS    coderanch.com

There doesn't seem to be a simple way to say something like this: SomeControl.setFocus(true); It seems you have to understand something called a "focus transversal policy" just to set focus to a control. I can't seem to find any good information on how to do what, IMHO, should be straightforward. While I understand the power that the current J2SE 1.42 gives ...

38. Retaining Focus in Swing    coderanch.com

I tried but doesn' work. This is what I am doing...please let me know if I am wrong: In focusLost event, I said if length() is < 4 then show an error message on the bottom text area...and requestFocus() When I do not enter a value in first control and click on the second control...it does display the error message correctly...but ...

39. How to know if I got focus    coderanch.com

Hi, import javax.swing.*; import java.awt.event.*; import javax.swing.event.*; import java.awt.*; public class Table2 extends JFrame implements FocusListener { Object[][] data = { { "1", "2", "3", "4", "5", "6" } , { "1", "2", "3", "4", "5", "6" }, {"1", "2", "3", "4", "5", "6"} }; Object[] header = { "A", "B", "C" , "D", "E", "F" }; static JTable table; Table2() ...

40. Change Focus When Enter Is Pressed    coderanch.com

41. gui looses focus    coderanch.com

hi, i've a java application, which is quite big. sometimes the gui looses the focus, so the blue bar on top becomes grey. on click into the app it becomes blue for a moment, then grey again. but the hotkeys within the application still work and when i click into an editable textfield, the cursor is in there. but i'm not ...

42. How to build focus rectangle    coderanch.com

Hi does anyone have any idea how to build those rectangles that appears around an object when you clicked on it in wysiwyg software application like GUI designer in IDE and other paint software? I tried to use Rectangle, but it is not visible, I need to show which object is focused (clicked) to the user. Thanks!

43. Focus problem    coderanch.com

Thanks a lot that really helped to those with the same problemas i had, here's what i did: created this class: import java.awt.*; class Foco extends FocusTraversalPolicy { TesteVisual visual; Foco(TesteVisual v) { visual = v; } public Component getComponentAfter(Container focusCycleRoot, Component aComponent) { if (aComponent.equals(visual.txtAno)) { return visual.txtTurma; } else if (aComponent.equals(visual.txtTurma)) { return visual.txtNomeUtilizador; } else if (aComponent.equals(visual.txtNomeUtilizador)) { ...

44. help needed on the java-focus    coderanch.com

45. help needed on the java focus...    coderanch.com

46. Remove focus    coderanch.com

47. Setting Focus in a DeleteKeyListener    coderanch.com

I am trying to clear out a non-editable combo box using the delete key. The delete key has a listener attached to it, which tries to force the focus to the previous combo box when the delete key is released. This all seems to be working alright except that when the action listener on the previous combo box fires, I have ...

48. Initial focus    coderanch.com

49. getting the focus back    coderanch.com

Hi, I have a text field. I am doing some validation for that text field. If the user enters some invalid value and then presses tab, then appropriate message should be displayed. I am able to do this. I want to focus back on the same text field. How to do this ?? Thanks in advance.

50. Focus Problem    coderanch.com

51. I lack focus...    coderanch.com

Or rather, my JWindow does. Howdy, y'all! (would rather not post my code in full just because it's so huge... will post salient parts) (also might should have posted in the intermediate forum because of complexity, but I might be missing something simple and this is where most of the other focus questions are...) Here's the setup: I've got a several-part-program. ...

52. Focus Problem    coderanch.com

Hi, I have a focus problem.. I have some tabs and when I click on submit from nth tab,a validation will be thrown [as per reqt because of required field missing] and the tab which has missing details would be shown... the scenario where problem occurs is like this ... when I click on submit exception is thrown for first time ...

53. Focusing problem    coderanch.com

I am using a class which extends BeanPanel and implements BlackBox, Serializable.The beanpanel consits of textfields dynamically created on runtime depending on the columns of tables provided on runtime.There is no issues as such in all this arrangements the problem is with focusing. There is a panel of buttons next to this beanpanel. When someone tries to keyin values in a ...

54. regarding focus    coderanch.com

Hi, I have one problam in setting the focus to the applet. the problam is when i launch the Applet i need to set the focus on it, but the focus is not set to the applet as soon as it is launched. I am providing the print feature in the applet. Now i need to click on the applet to ...

55. Focus problem wiht Mac OS    coderanch.com

56. setting focus    coderanch.com

I've just tested it (again) and componentListener works fine, the 2nd or 3rd or whatever textField/passwordField starts off with the focus (java 1.6) these are the basic rules you have to follow for focus 1) use requestFocusInWindow() rather than requestFocus() 2) requestFocusInWindow() will only work if the component is visible, so, if you have pwd.requestFocusInWindow(); frame.setVisible(true);//where frame, in its hierarchy, has ...

57. Question on setting focus    coderanch.com

Hi there, I have a Jtable in a scroll pane and below the Jtable I have 2 panels which have theirs sets of controls. The Question which I have is 1) If I make the Jtable Focusable it actually just keeps traversing the Rows and never gets to the nextFocusable control which I set it to. Is there any way to ...

58. preventing focus in swing gui    coderanch.com

Hi, I'm working out a handwriting recognition system for my Linux tablet. I'm finding out solutions to the various issues, and then I'll design it properly, once I know what's needed. I've got much of it working, but I am having a problem with the gui. In order to work, it needs to not steal the focus from other windows - ...

59. Focus    coderanch.com

60. doubt in focus    coderanch.com

A really interesting topic. But by design point of view you are not supposed to decide actions based on how focus changed. Anyway...I guess there may be some solutions. I can't post code for reasons, but can give you some ideas... If you want that only TAB should control focus. For this use the following API in Component setFocusTraversalKeys(). Use this ...

61. regarding focus in swing    coderanch.com

62. Focus gaining    coderanch.com

63. Focus problem    coderanch.com

because they're internalFrames, you may have to get a bit lower in the event chain then keyBindings here's a couple of ways to do that (in this e.g. using a button with mnemonic). new problem is when jif1 has the focus, both mnemonic and the added code trigger the button's actionEvent - so you may have to remove the mnemonic import ...

64. Unfocusable and not resizable    coderanch.com

Being first confronted with SWT I can't find the screws/switches to open a control with the following properties: 1. It must have a fixed size, the user should not be able to resize it, but it must be moveable around freely. 2. Under no circumstances should it get (keyboard) focus but get the mouse events. Think as if it was an ...

65. Detect Loss of Focus For Entire App    coderanch.com

66. Regarding Focus    coderanch.com

Hi, I have few textfields and a submit Jbutton. But when i want to press the button i should bring the focus on it by using the mouse or the TAB key. My need is that when i fill the fields and press the enter key the button should be pressed. Can any body please help me regarding this. Thanks & ...

67. REG: Focus    coderanch.com

68. Reg: Focus    coderanch.com

69. Java 1.6 focus returning problem    coderanch.com

70. Focus: cant find the relevant method    coderanch.com

i've this application with several tabs to one of them i wrote a custom FocusTraversalPolicy class the idea was pressing the tab key to move across several text fields, what i got done (forward and backwards too) now i wanted to have the first text field with the cursor in it, so that i could start writing without having to click ...

71. Focus Problem    coderanch.com

72. Option dialogue box not getting focus    coderanch.com

Hello, and welcome to JavaRanch! I doubt anyone will be able to figure out your problem given the information presented. You may want to create a very small compilable program that demonstrates your problem and that we can run on our machines. Do this and I predict your odds of getting a helpful solution to be > 90%. Much luck!

73. How we can set focus?    coderanch.com

I have developed a program in which when i click on a button, A new text field is created... Suppose i clicked on the button 10 times, 10 text fields will be created... The cursor lies on the very first textfield, I want that cursor should be on the last field created... How is it possible... I think that this is ...

74. Loss of focus while coming back from the External browser to swing awt application    coderanch.com

Hello All, We have an Swing awt base application which is internally calling the External browser using the JBrowser.dll When we come back from the any external web application we get some values to process back. After processing those values we are redrawing the view of the Swing application. However at this point of time we are not able to get ...

75. Problem setting focus for a newly added child element in TreeViewer    coderanch.com

Hi My treeviewer contains both parent and child elements. When I am trying to add a new child element for a particular parent element, some how the focus is getting lost. My code goes like this protected void setSelectionToViewer(final Collection theSelection) { if (theSelection != null && !theSelection.isEmpty()) { // Try to select the items in the current content viewer of ...

76. focus problem    coderanch.com

There's not much here to go on. Are you creating a Swing application? Does the application display? What happens when you click on a component in the application window (like a text field or a button) - do they respond? Try creating a simple application and see if it shows the same problem. If so, then you can provide that application ...

77. Any one Can help me with Focus system?    coderanch.com

Hi All, I am just trying to make a login form for my application which has username text field and password text field. the application is a touch screen application, so I am just planning to make a on screen key board with login form in the same screen something like the attched picture My problem is: how to define action ...

78. AWT Focus Problem using idk 1.6.0    java-forums.org

Hi, I m working on a system which GUI is Swing based previously on JDK 1.4.2, recently we are upgrading our environment and moving on JDK 1.6.0. We are facing a component focus ordering issue on screens having BoxLayout. In previous jdk 1.4.2, the focus order was same like order of adding textboxes or other components on the panel but now ...

79. Transfering Focus    java-forums.org

I have been working on trying to transfer focus and have not been successful. What I'd like is to recreate how menus work. For instance I want a user to mouseDown on a button and have a frame displayed receive focus to capture mouseMoved events without having to release. Any ideas? I'll paste some code. Thanks. import java.awt.*; import java.awt.event.*; import ...

80. focus issue in java 6    java-forums.org

Hi all, i have a issue with java 6. after displaying printdialog and clicking 'ok' or cancel, doesnt return focus to the application. the application focus is lost. how to solve this issue? The part of the code i am attaching here public void printDrLicBondCardRtnEnvelopes() { new Thread() { public void run() { printEnvelopes(); } }.start(); } public void printEnvelopes() { ...

81. java 6 focus issue    java-forums.org

Hi all, i have a issue with java 6. after displaying printdialog and clicking 'ok' or cancel, doesnt return focus to the application. the application focus is lost. how to solve this issue? The part of the code i am attaching here public void printDrLicBondCardRtnEnvelopes() { new Thread() { public void run() { printEnvelopes(); } }.start(); } public void printEnvelopes() { ...

82. add JToolTip on focus gained forJTextField    java-forums.org

thnx man, but what i need is when i set focus to text field it takes a time to display the tooltip and i want describe the case for u: i have a jtextfield when i set focus into it i want to show tooltip thta shows a description about it and i don't want to disappear that tooltip until the ...

83. focus in SWING    forums.oracle.com