In Swing, how can I find out what object currently has focus?
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 object name? Thanks ...
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 object name? Thanks ...
Hi I have a GUI application that is working fine. I created a socket server. When I create a new object of the Server class in program the GUI application stops responding. This is my server class. If I do Server s = new Server(); in my main application it stops working. How should I add it? Making a new thread? I tried Thread t...
The swing-UI of Java-programs doesn't work perfectly together with the awesome-wm. awesome is a window-manager for UNIX, that automatically resizes program-windows, and the Swing-UI doesn't recognize these resizes correctly. I don't care if awesome or Java is guilty, what I wanna know if I can change my Java-programs in a way, that they ...
I'm messing around with DefaultStyledDocument and am trying to figure out the right way to set a style to the proper monospaced font. By "proper" I mean that the font selected is: A monospaced font that exists on the user's machine A font specified by the user's preferences (is there a standard way to do this in Java?) If there is no s...
I'm working on a java swing application that will be used in a psychology experiment and the researchers have requested that I make the program "black out the screen" in order that there should be no outside stimuli for the user. They want the swing app to be truly full-screen and without any type of title bar or minimize/maximize/close ...
HTML can be used in Java swing GUI components, like JTextBox, JButton, ... etc. Is there an equivalent to that in .NET (C#) WinForms? or at least some simple way of making a single word bold inside a textbox without using another GUI component? ...
I want to create a TextArea in java where i can write data in chinese. How can I achieve this Thanks Bapi ...
I'm starting a fairly complex Swing application that heavily graphics-oriented with about 1000 separate jpegs, 30+ different forms, and timers keeping track of the rate of user-interactions throughout. My question is from a practical programming perspective, after I've already written a storyboard for the entire project and got it appro...
How can I forbid users to put blanks into a JTextField? It should not even be possible to write blanks. ...
I'm trying to use fixed width fonts in Java. I can use Courier or Lucida Console, but when I apply a "bold" style, it makes the characters larger in width and that's not acceptible in my application. Is there anyway I can force the bold characters to have the same width as non-bold characters? ...
Here's a very specific coding question: I've recently been asked to maintain some old-ish Java Swing GUI code at work and ran into this problem: I've attached my own subclass of InputVerifier called MyFilenameVerifier to a JTextField (but it may as well be any JComponent for these purposes). I've overridden the verify() method such th...
I have a JTable with a set of uneditable cells and I want all the cells in a particular column to have a different mouse cursor displayed whilst the mouse is hovering over them. I am already using a custom renderer and setting the cursor on the renderer component doesn't seem to work (as it does for tooltips). It does seem to work for e...
I am printing a Swing component that contains text. The Swing component renders the text just fine on the screen, but, when I print it (to a .tif file), the characters are all smashed together. Why is this? Run this code to see what I mean: import javax.swing.*; import javax.swing.text.MutableAttributeSet; import javax.swing.text.Sim...
is there a list somewhere of the UIManager.getColor() keys for Swing? I can't seem to find it online, just occasional references to strings like "Panel.background" and "Table.selectionBackground". ...
How can I have one window move with another? i.e., I'd like a JDialog to follow a JFrame when the JFrame is being dragged. If the JFrame moves by (+5, +20), the JDialog needs to move the same. I've tried using ComponentListeners, but I only receive drag events in chunks which causes the JDialog window to be jumpy while dragging the ma...
I have a Swing application, and even though I have everything in a try/block, the exception isn't caught. public static void main(String[] args) { try { App app = new App(); app.setVisible(true); } catch (Throwable e) { System.err.println("never printed"); } } all I get is this stack trace: Exception in threa...
Item is a simple model class. ItemComponent is a view for an Item which just draws simple rectangles in a given spot. A bunch of ItemComponent instances are put into a parent component that is added to the JFrame of the application (just a simple shell right now). The view has two different display styles. I want to adjust some proper...
I know this is gonna be a stupid question. Pardon me as a n00b into CS I have a new swing component that inherits from JComponent. I am trying to paint lines on its surface to show that the lines split the control into equal parts. The code looks like int spc; spc = (int) Math.round((this.ZBar.getWidth() / this.ZBar.getModel().getModel...
I'm looking for an efficient keyboard input system for a game in Java. At present I'm using some code I found here: Keyboard Input Polling System it seems a little inefficient however (please comment as to your thoughts on the code). The full code is available here: Pastebin Code I've only just started looking into a new solution a...
Any time I make a custom cell renderer for a JList, any elements I add to it don't ever respond to actions. For instance, If I have the cell renderer return a JPanel with elements on it, one of which has an ActionListener, it doesn't respond at all. Why is this? ...