swing

How to get the same value as the user is seeing from a JFormattedTextField?

I'm using a NumberFormatter and JFormattedTextField, but the .getValue() doesn't return the same value as the user is seeing. I think the input-string is parsed using NumberFormats parse-method, and I get the Numberformat from NumberFormat.getNumberInstance(); with the actual Locale. So I don't think I easily can extend it and write my ...

Cut and Paste in JTextArea

Hi!, I'm developing an application which requires that only 165 characters to be in the JTextArea. I've imposed that condition. I've used a static counter for counting number of characters entered in the textarea and also coded to handle the condition when user deletes any string from the text the counter must be incremented by conside...

Java Data Persistence without Enterprise Server?

What solutions exist to persist data, without requiring a full-blown enterprise server? I am fairly new to Java. At uni the whole curriculum was based on Java, so I coded a bit already. But it never went into depth with the available frameworks. The only way we actually touched on persistens was using "vanilla" JDBC connections. I've do...

Java Swing display stops updating until X event generated

EDIT: additional info at the end I've got a (large) Java Swing application that's demonstrating some very strange behavior. If the computer running it is left idle (no mouse or keyboard input) for a sufficiently long time (varies between an hour or so and a couple of days), the Swing display sometimes stops updating totally (we've got,...

Menu items become disabled in Mac when an "AlwaysOnTop" frame is showing

I have some frames that have the property alwaysOnTop set to true. If this frames are showing and the main frame shows a modal dialog, all menu items stay disabled until the application is restarted. It looks like an apple java bug Any thoughts of a fix? ...

How do I change the background color of a frame in Java from another class?

Hi, I have the following: import javax.swing.JFrame; public class Directions { public Directions(){ JFrame frame = new JFrame("Direction"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new DirectionPanel()); frame.pack(); frame.setVisible(true); } ...

Java: is there a SwingUtilities.invokeNowOrLaterIfEDT(...) or similar?

(be sure to read the edit below, this question is obviously confusing I'm sorry about that) Here's a typical SwingUtilities.invokeLater call: SwingUtilities.invokeLater( new Runnable() { public void run() { ... } } ); Now I'd like to have what would be a SwingUtilities.invokeNowOrLaterIfEDT. Of course I could use ...

Java - How do I prevent BorderLayout EAST from hugging the side of the screen?

If I add components like JButtons on the east or west side, how do I prevent it from hugging the side of the screen? I want some space between the JButtons and the edge of the screen. ...

Pictures in a JPanel

hi, I'm trying to write an application where I want to add different pictures on a Jpanel. Everything works fine except for the JPG format which displays very bad quality images. This is how I do the drawing : class draw extends Canvas { Dimension canvasSize = new Dimension(400, 400); String fileName; public void paint(...

Accessing the pixels of an image

Could someone show me here how to access all the pixels of an image in order to be able to build a histogram of that image ? ...

Java Swing Maximize button of JFrame disappearss

I have created a java frame. It contains a JSplitPane. In the right partition of the splitpane , I have put JTextPane. Now I have kept JButton somewhere on the frame. When I click the button, a new JTextArea is inserted in the JTextPane as follows JTextArea newTextBox = new JTextArea(1, 1); StyleConstants.setComponent(style, newTextBox)...

Java JTable with frequent update?

Hi Everyone, I'm coding a JTable that is capable of handling frequent updates. Typically this JTable has ~1000 rows of data, and some of the columns will update frequently because their values are derived from stock price which moves a lot during market hours. The problem I'm facing is that when large # of rows (e.g. 80%) are updati...

Java: Deleting a GUI object from within the GUI

Hey Guys Can you help me out here? A really simple problem but I just can't get what the solution is! I am coding a listener application that runs on its own thread & listens on a ServerSocket for incoming connections. When a connection arrives, a new 'Message' object is created on a new thread and passed the incoming text data "messa...

Java Swing: separating UI component from logic behaviour - how do you approach this?

What I do, in NetBeans for example: create a UI component class, suffixed with Swing component type, e.g. JPanel, e.g. MyUIWidgetJPanel create a logic/behaviour class to handle the behaviour/logic, i.e. what happens when the UI component is used, e.g. buttons within it pressed etc., MyUIWidgetLogic I may also link components/logic to...

What does this "Image Fetcher 0" is doing?

While debuging a swing application I saw this thread appears quite offen. There is a another thred call "Image Fetcher 1" also. can someone please explaint to me what does this thread do. Is it realted to "SwingWorker" Thread. ...

Controlling the preferred size of a JEditorPane with long text

I have a JEditorPane which is displayed inside a popup, triggered through a button. The pane contains long text, therefore it's nested inside a JScrollPane, and the popup is constrained to a maximal size of 300 x 100: public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override publi...

Swing java properties file editor

I am writing an Swing application that uses java properties file to store the application configuration. Currently the file needs to be edited manually I am looking for a free Swing library that I can integrate into my application so the editing is more user friendly. ...

Focus debugging in Java

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 in code this is happening. What I have tried: A VetoableChangeListener with KeyboardFocusManager (for focusOwner). This does give me information about...

Swing: table with header row

I have a table showing a list of objects; let's call them Employee for clarity's sake. The table shows Employee objects that are child objects of a given parent object which is also an Employee. What I would like to do is show a special header row with the parent object, either above (if possible) or below the normal column heading, but...

Resource files with Swing Application Framework

Could someone explain how I should use resource injection when I have several packages in my application? I seem unable to load resources in any other package but the one where I have the SingleFrameApplication descendant. Let's say this is what my application structure looks like: /resources /main /main/resources /view /view/resources ...