swing

Searching for a Java layoutmanager which hides elements if space is getting short

Hi, I'm searching for a Java layoutmanager which is able to automatically hide (less important) elements, defined by me, if the user scales down the window size. For example an icon in a row of a label and a JTextField, which is only there to visually enhance the form. If the user resizes the window to a minimum size, the icon should d...

In Swing, is there a property to set a JList disabled foreground color?

In Swing, is there a property to set a JList disabled foreground color? I'm using the Netbeans GUI builder and I want to add a property to the resource properties file that sets the color of the text in a JList to a different default when the JList is disabled. Using the Nimbus LAF, there is a different color for this because the text ...

Vertical Stacking like GTK in Java Swing?

I want to stack JComponents vertically, similar to a JList, but since the amount of items is very low and I want a highly custom interface - I wanted to try a vertically stacked set of components. ...

Java - best library to help draw text at arbitrary anchor points

Hi all, I'm familiar with how to use the various FontMetrics functions to center text vertically, horizontally, and whatnot. However, I am looking for a library that supports drawing text at a given xy location relative to the string (e.g. I want the center of the string at x,y, or I want the upper right corner of it to be here, etc.) ...

How show my application delay with JProgressBar???

Hello guys I wrote a simple application and I want show delay of it with JProgressBar Plese help me ; I want show JProgressBar with Joptionpane , with a cancel button and it should be modal this is my source code : class CustomFrame extends JFrame { private JProgressBar progressBar; public CustomFrame() { long start = Syst...

Java Swing: Recalculating values in a JTable, to use the TableModel or write a custom editor?

Hi, I use a JTable to display data sourced from a streaming data feed. Each data point is represented as an object of type X, which has one field of interest, lets call it valueField. My implementation of the TableModel interface has a HashMap of objects X keyed on X.getId(). The users of the GUI are able to change the values us...

What should I do on exceptions thrown by SwingUtilities.invokeAndWait

SwingUtilities.invokeAndWait() throws an InterruptedException and an InvocationTargetException how should I handle these? public static void invokeAndWait(Runnable doRun) throws InterruptedException, InvocationTargetException I want to use the method to show a dialog and wait for the user to say yes o...

Showing Data in JTable with Max Count.

Hi, There is a jbutton in my Jpanel , when i clicked it , it loads up my Jtable , sometimes a query return so many records (500 rows). So i wanna restrict it with 5 record.When query return i wanna count it if its higher than 5 then Jtable shows up only first 5 record when user click Forward button it will shows up next 5 record.When us...

removing mouse events/controls from swing components with glasspane

Hi all, I have a client-server application and i am using swing in the client side. My swing client has one main window (jframe) and lots of panels, toolbars and menubar in it. I want to remove all client action/mouse events (or simply grab and do nothing) while client is waiting response from server by means of glasssPane. Here is the ...

What should I choose SWT or Swing to program GUI in Java?

I need to create a GUI application in Java. I just realized that I have different optional ways to go (SWT and Swing are among them). I have already found out that there is a lot of discussions about what way is better and I do not want to go to deep into these discussions (I am a newbie). I do not care about all aspects of the dilemma...

setBorder on JTextField does not work ? or does it ?

The code is like this: JTextField txt = new JTextField(); txt.setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.red)); However the text field is ignoring my call to setBorder. No changes whatsoever. I were to replace it with a JLabel (for instance) JLabel txt = new JLabel(); txt.setBorder(BorderFactory.createMatteBorder(2,2,2...

Why my Swing based GUI application is not responding?

I am trying to create my first GUI application using (Java + Eclipse + Swing). This is my code: import java.awt.*; import javax.swing.*; public class HelloWorldSwing extends JFrame { JTextArea m_resultArea = new JTextArea(6, 30); //====================================================== constructor public Hell...

Swing JTextField how to remove the border?

Is there anyway to remove a border in a JTextField? txt = new JTextField(); txt.setBorder(null); // <-- this has no effect. I would really want it to look like a JLabel - but I still need it to be a JTextField because I want people to be able highlight it. ...

How the Swing Hello World application works?

I am trying to figure out how the Swing based Hello World application works. This is the code I have: import java.awt.*; import javax.swing.*; public class HelloWorldSwing extends JFrame { JTextArea m_resultArea = new JTextArea(6, 30); //====================================================== constructor publi...

tooltip causing deadlock in swing/netbeans-rcp

Hi I have a netbeans platform based app. It has an outlineview, with several columns. when i have my app maximised. and hover over the right most column to display the tooltip (that has to be adjusted due to end of screen). the application hangs (or rather, eventqueue is blocked). Sometimes it starts running again after a few seconds, ...

Why are my JFrame contents not being painted sometimes?

I am trying to construct a basic control that will display an undecorated JFrame right below it when a button is clicked. I am trying to mimic drop down type functionality, but with my own Frame instead of a panel. My component contains a class member of the JFrame derived control that I would like it to show. In certain situations, w...

Add transparent JPanel upon AWT Component to paint on

Hi, I've got a Problem: In my Java application I've got an AWT Component (cannot change that one) that streams and shows an avi-file. Now I want to draw upon this movie and thought about putting a transparent JPanel above it and draw on that one. This does not work since I either see the avi-stream or the drawn lines but not both. I r...

How do I add ScrollPane to a panel in Java?

I want to add different buttons, vertically stacked, to a JPanel at run-time and use a JScrollPane so that all buttons will be visible (with some scrolling). In order to do this, I have added my JPanel to a JScrollPane, after which I add buttons to my JPanel. However, when I do this the vertical scrollbar does not allow me to see all i...

Java swing small 2D game: how to modelize the view?

In a small java swing 2D game, what is the best solution for creating the board view? Use a component for the board and custom paint it and each square of the checker at once? Use a component for the board and create another component modelizing the square with its own paint component doing the job for the square only. Use a layout to ...

can JMS used in Java Swing App

I need to design a Swing application, which will need to send out multiple jobs as customer requested. each job is running the same shell scripts which will take 10-30 mins to return a value. (the jobs are not running on application server or as web services. )then the Swing application will need to decide what to do next according to th...