swing

JAVA-I don't want clicking on my app make other apps lose focus

Wow, what a stupid question you might say. But is it possible? I have a mouse move event in a Jpanel and it works even when the application is not in focus, now can I have something like that for the clicking event or something similar. And most importantly I don't want other apps (even something like the main menu) to lose focus when i ...

How to use CellRenderer for GregorianCalendar?

So I have been trying to use the example from Tutorial and change it so it fits my program. The getColumnValue method returns the object that holds the information that is supposed to be displayed. Is this the way to go or should it rather return the actual String to be displayed. I guess not because that way I would mix the presentation...

Change the look of Swing.

Is there a way to change the standard look of Swing components? Those default, look just pathetic and hopelesly unattractive. Thanks. ...

Setting minimum size limit for a window in java swing

I have a JFrame which has 3 JPanels in GridBagLayout.. Now, when I minimize a windows, after a certain limit, the third JPanel tends to disappear. I tried setting minimizing size of JFrame using setMinimumSize(new Dimension(int,int)) but no success. The windows can still be minimized. So, I actually want to make a threshhold, that ...

How can I customize the title bar on JFrame?

I would like to have a customized title bar in my Java Swing desktop application. What is the best way to do that? I can use a "Swing-title bar" by using the following code in the constructor for my JFrame: this.setUndecorated(true); this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); But how do I customize it? Is there any ...

Swing: Programmatically select a text

Hey everyone, I have a very simple Swing GUI with just a JTetxtArea. I am trying to programmatically select a part of text using: textArea.select(startSelection,endSelection); This work. However as soon as I add some other components to the GUI I do not see selection anymore frame.getContentPane().add(button); frame.getContentP...

how to disable JList selection change event and invoke it only on double click ?

As the title says... I'd like items in a JList to be "selected" only when they are double clicked. what would be the best way to achieve this kind of behavior ? ...

How to make my Java Swing application a Client-Server application?

I have made a Java Swing application. Now I would like to make it a Client-Server application. All clients should be notified when data on the server is changed, so I'm not looking for a Web Service. The Client-Server application will be run on a single LAN, it's a business application. The Server will contain a database, JavaDB. What t...

How to delete Drawn Line in java?

Hello Folks, well this is my code: import javax.swing.*; import javax.*; import java.awt.*; import java.awt.Color; import java.awt.Graphics.*; import java.awt.event.*; import javax.swing.UIManager; public class SimpleGUI extends JFrame{ public SimpleGUI(){ this.setDefaultCloseOperation(JFrame.EXIT_O...

DefaultStyledDocument.styleChanged(Style style) may not run in a timely manner?

I'm experiencing an intermittent problem with a class that extends javax.swing.text.DefaultStyledDocument. This document is being sent to a printer. Most of the time the formatting of the document looks correct, but once in a while it doesn't. It looks like some of the changes in the formatting have not been applied. I took a look at...

Java swing doesn't show changes to source

I'm using Java Swing graphical editor with netbeans to make my project...but using it brings some limitations like I can't add to a jpanel an image,using java swing options. So i'll need to code it, implementing a new jPanel. My problem is that the code generated by the java swing graphical editor can't be edited so instead of adding t...

Java Swing app hangs when run in normal mode but runs fine in debug mode

I am writing a basic Java application with a Swing front-end. Basically it loads some data from a Derby database via Apache Cayenne and then displays it in a JTable. I'm doing my development in Eclipse and I don't think it's important but I'm using Maven for dependencies. Now this works fine when I run using Debug but it seems to hang t...

Visual Editor vs Manual code

I'm not sure how it is using other frameworks but this questions is strictly regarding Java swing. Is it better to use a Visual Editor to place objects or to manually code the placement of the objects onto the frame (Layout managers or null layouts)? From my experience I've had a lot of trouble using Visual editors when it comes to dif...

Wrong background colors in Swing ListCellRenderer

I'm currently trying to write a custom ListCellRenderer for a JList. Unfortunately, nearly all examples simply use DefaultListCellRenderer as a JLabel and be done with it; I needed a JPanel, however (since I need to display a little more info than just an icon and one line of text). Now I have a problem with the background colors, speci...

How do I add mouseClicked event to a swing table?

Hi, I am a new, terribly green user of Swing. I managed to create a table class using examples from java.sun tutorials, and I managed to load data dynamically into it. I want to be able to react to a click on a row by displaying a dialog box. How do I add the event Handler that will identify the selected row number? The main function...

java.lang.IllegalStateException while using Document Listener in TextArea, Java

DocumentListener dl = new MessageDocumentListener(); ((AbstractDocument) nboxArea.getDocument()).setDocumentFilter(new DocumentFilter() { public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException { string = string.replaceAll("\t", ""); super.insertString(fb, of...

How do I make the main window to react to a table click

I am a new user of Java swing. I need to be able to create a popup with row info when the user clicks on that row. I managed to incorporate the mouseClick event reaction in my table class, and I have the row info available. But I don't know how to notify the main window about the event so it can display the dialog box/popup box. Ca...

Why is this JLabel continuously repainting?

I've got an item that appears to continuously repaint when it exists, causing the CPU to spike whenever it is in any of my windows. It directly inherits from a JLabel, and unlike the other JLabels on the screen, it has a red background and a border. I have NO idea why it would be different enough to continuously repaint. The callstack ...

tiled images in swing

I have task to prepare two windows with swing. One contains grid of squares, with random numbers in them. In second I need to load pieces of tiled image and then show them in the correct order, forming tiled image. Windows should look like this : Okay so how to bite this ? I've used swing only few times to draw some 2d polylines, so ...

Java monospace draw string

Hello! How can I draw a String in Java (using Graphics2d) in monospace mode? I have a font that looks like LCD screen font, and I want to draw something like LCD label. I am using Digital 7 Mono font. Do you know where I can find another font that will be monospace and lcd (I wan to type only digitals)? ...