swing

java how to get top level container of a compoent?

is there a way to get the top level container of a component? For example I have a JToolbar and I want to know at one monent the top level container of that JToolbar is my JFrame or is its own window, a JDialog. ...

how to know JToolbar's status?

How to check the JToolbar is docked on my JFrame or it is draged out with its own window? ...

Best way to implement refusing a value change by the user in Swing?

I have a JCheckBox that should not be checked by the user when a certain other field is empty. So now I want to have an error popup and then reset the checkbox (I've considered disabling the checkbox, but the connection to the other field is non-obvious, and a tooltip text IMO not visible enough). What's the correct way to do that in S...

how to have more than one JToolBar in one screen?

How to put more than one JToolBar on one screen and allow them floating. Usually we put JToolBar on a container with BorderLayout. if we put all JToolBars on a panel then put the panel to the container, we will have problem to allow them floating. any ideas? ...

Why Java Swing behaves different on different systems?

Some swing code I write in my computer behave different on my colleague's computer, and in my PC, and in my notebook. I wonder, is there something I can do to my Swing applications behave the same in every computer? I want to have sure a algorithm I've tested in my computer will work the same way in my clients computers. E.g. Problem ...

Cross developping targetting both Java Swing and GWT

Does anyone know of any tool that can facilitate/ease porting of an app to both Java Swing and GWT? I've got a few "screens" that makes complete sense to have both in a desktop app and in a browser and I was wondering if there was some kind of common API that could be targetted that would facilitate creating these two different "views" ...

Swing combo boxes

Alright, so I'm simply defining a combo box like so... JComboBox yearSelect = new JComboBox(); Now, I have not even added this to a panel or anything, I've just defined it. When I run the app, nothing displays.. when I comment out this line.. the app displays the other panels like I want it to.. is there something I'm doing wrong? Ma...

need to remove maximize and minimize buttons from jframe to reduce width further

I need to remove maximize and minimize buttons from jframe to reduce width further. Please suggest how can i do that. ...

java:I am trying to create Shotcut of any abc.exe through java program.

I am making an installer in java swing it almost completed only one thing is left to do that is to create desktop shortcut of our software.I do not want to copy software on desktop but I want to create instance of that software like other MS software. How it can be done please help me. I am already copied my software in c:/Program file...

adding flash in swing components

I am creating a swing application, I like to add Flash in that application. Can we add flash in Swing components? Thanks... ...

Problem with resizing columns in a double JTable

Hello, I am creating a custom component containing 2 JTables, one as the main data grid and other as the always visible summary bar and I have come up this solution, but resizing columns is not working as it should be, any ideas what have I done wrong? import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.Wind...

Can actionPerformed return a value?

In my application I use a FileChooser to chose a file. The name of the selected file should be returned to another class. how to do this in eclipse? ...

MouseMotionListener inside JTable

I am trying to add MouseMotion event to the label and move it based on the dragging of the mouse and make it move along with my mouse.However the mousemotion is very difficult to control making this action not usable. Here is the code import java.awt.Color; import java.awt.Component; import java.awt.event.MouseEvent; import java.awt.ev...

Java Swing TanleModel fireTableRowsInserted on EDT

I have a TableModel that is populated from a background running thread. I am calling fireTableRowsInserted when data is inserted, which is NOT on the EDT. My question is, do I need to use invokeLater for the fireTableRowsInserted? In other words, is the below correct: public void putData(TableRow row) { // we are not on the EDT...

StackOverflowError being caused by a TableModelListener

I'm not sure why this is recursing. jTable1.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent evt) { int sum = 0; int i=0; for (i =0 ; i<2; i++){ sum = sum + Integer.parseInt(jTable1.getValueAt(0, i).toString()); } jTable1.setValueAt(sum, 0, 2); } }); The exception i...

Equivalent to Android's Toast or Mac OSX Growl in Java Swing?

Hi all, Looking for a means of displaying transient, non-modal dialogs in a Swing application. In other words, I'd like to pop up a semi-transparent box with some text in it that can be immediately dismissed, or will fade away in a set amount of time. Is there a library to do this? I don't want to reinvent the wheel if it already exi...

Pie, Bar, Line charts in java?

I want to use Pie, Bar, Line charts in java. What is the best API to use them? Is there any API by Sun to create these types of charts? ...

Java Swing transparent JPanels problem

I'm having A JLayeredPane where I add 3 JPanels. I make the JPanels transparent (no background is set and setOpaque(false)). I draw lines on the JPanels and only the line on the last JPanel which has been added is visible. The lines of the other JPanels are not visible through that top JPanel (even if I have added different zIndexes whe...

Format a number as currency in a JTable?

Given a JTable where one of the columns contains a number, how do I display this number as a currency? I.e. 5 should display as $5.00 etc. Can this be done directly on the JTable after it has been populated with data, or do I have to do this earlier? Thanks. ...

Java Disabled JLabel Reports Mouse Clicked

colLabels[i].addMouseListener(new MyAdapter()); private class MyAdapter extends MouseAdapter { @Override public void mouseClicked(MouseEvent event) { ColJLabel colJLabel = (ColJLabel)event.getComponent(); System.out.println(colJLabel.ColID); setColumnHeader(false); } } colLabels[i].setEnabled(flag); The si...