swing

Java swing jLayeredPane

I have an code that adds jbutton on the clicked place in the jLayeredpane on mouse click. Now the problem is on resize. When i dont change the size of jLayeredpane on runtime there is no problem. When i maximize the window and i have made it as, the jLayeredpane will adjust to fit the screen so when i add a button on the jpane now and wh...

BufferedImage imageType in swing

I'm writing a widget that does some caching to avoid unecessary calls to Shape.draw on a bunch of shapes at every repaint. I've tried to do something like this (scala code): private val buffer = new BufferedImage(width, height, /* (1) */) ... override def paintComponent(Graphics2D g) = { if (hasChanged) { val bg = buffer.getGrap...

JTable very slow

Hello, I have a JTable in a swing application. I wrote a quick and dirty un-dock operation where the JTable is removed from its default parent and gets added to a seperate JFrame. When the JTable is undocked and placed on a seperate JPane it is REALLY slow at moving around in the JTable... as soon as I dock it back into its original pl...

What is a good strategy for seprating layers for an appication that can be used online and offline?

I have a Java web application that has a 'disconnected' Java Swing desktop app. Using the desktop app users connect to the internet and download data they need from a server. They can disconnect and use the application offline. When they reconnect to the internet they can sync their data back to the server. The server itself is a Java...

Java - Is It Possible To Add A JMenu Over On The Far Right-Hand Side Of A JMenuBar?

Hi Coders, I am in the process of developing a simple JFrame based GUI to which I've added a JMenuBar and which in turn has the usual JMenuItems added to it - "File:", "Edit:", etc. I would like to be able to add another JMenuItem - "About:" - to the far right-hand side of the JMenuBar. Is this possible without too much hackery - I w...

Java - Swing GUI renders incorrectly in Windows 7

Hello! I'm building a Tic Tac Toe game in Java with a Swing GUI, and it renders correctly in Ubuntu 10.4 and Windows XP. This is how it looks like in Ubuntu: When I copied the bin-folder with all the class files and tried to run the program in Windows 7 it looked like this instead: I just can't understand what's wrong. As I said,...

how to remove comma from textFiled in Java

Hi all I had a jFormattedTextField with Name Hectare. the value is declared as double as shown below String cultivationSize = jFormattedTextField3.getText(); double hectare = Double.parseDouble(cultivationSize); now the problem is when i enter more than 3 digits the by default comma is entered after 3digits as 1,000...

Swing Applications Always Starting Maximised

Swing applications always start maximised on one of my computers, but not on others. I've posted about this issue on the Sun Java forums without any solution being found. I tried uninstalling the JRE and reinstalling it to see if that would fix it, but it hasn't. Does anyone have any ideas? ...

How to set right alignment in JTable cell?

I am creating one application with billing facility, In that I want the amount column only display in the right alignment. Can anyone suggest me? Thanks in advance. ...

Closing Swing JTabbedPane tabs in Java 1.5?

Java 6 introduces "Tab Components" and allows you to add arbitrary components to the tab. But, if you're stuck in Java 1.5, and need to provide the same use case, what are the alternatives? (I just need users to be able to close tabs...there has to have been a workaround for this prior to the release of Java 6.) ...

Java Swing add/remove jButtons on runtime

My application has a module which allows the user to add jButtons on the jLayeredpane during runtime. I want to add action listeners to this dynamically added contents and also i have to provide access to delete the dynamically added buttons during runtime. Is there any way to do this ? private Map<String, JButton> dynamicButtons; publ...

Java Swing; is there a way when clicking a button, a popup will appear NEXT TO THAT BUTTON

Hi. I have a JButton that has a callback function like so: myJButtonCallBackFunc (ActEvtListener evt) { myFrame.pack(); myFrame.setVisible(true); } The myFrame pops up on the upper left hand corner of the screen. My question: is there a property that controls where the pop up pops up? Thanks ...

Java action listener question

I am creating a custom JPanel element (a login form). I want to allow people who use my panel to subscribe/listen to an event called "loginSuccessful". What is the best way to implement this in my JPanel object? UPDATE: oh and i also want to add that when that action is triggered, i also want to return a "User" object containing the ...

How to create component that does't give focus to the Window

I have JTextField with FocusListener that call textfield.grabFocus() every time when textfield lose focus. But unfortunetly, it allow parent Window to react on user action. Is there any way to don't give the focus to the Window using only JTextField methods? ...

Determine the value between 2 points in JFreeCharts

Imagine an XY Line Chart. The X axis is a number range, as is the Y axis. There are 3 series on the chart The domain cross hair is NOT locked on data: plot.setDomainCrosshairLockedOnData(false); I would like to know what the Range value is for each of the three series for the selected DomainCrossHair values. The issue is not each s...

Java Swing - Deleting rows from table with AbstractTableModel()

Hi, I have a table off AbstractTableModel. The data in the table is stored in a Vector. Now, when I remove a row, I am removing it successfully from the vector, but this is not getting updated in the view i.e. in the GUI. I read elsewhere that I need to use fireTableRowsDeleted(), and I am trying to call it inside a wrapper method in ...

Linking JComboBox & JTable

Requirement: I have a list of strings displayed in the ComboBox. Each of these Strings can have some properties. These properties are displayed in PropertyTable. ComboBox's selected Item's properties are displayed in the table. In addition, we use PropertyTable for editing or setting property values to the selected item in the comboBox. ...

jButtons resize on runtime

I want to resize the JButton at runtime by clicking on its border and draging it. Can anyone explain me how to do it with a sample code. public void mouseDragged(MouseEvent E) { Point point= E.getPoint(); //JButton get = floor_plan.dynamicButtons.get(E.getComponent()); JButton get=(JButton) E.getComponent(); int height = get.getHeight(...

Java GUI Crash happens over VNC!!!

Hi!! I have a Java GUI based Application. When I run it on Windows it works fine. But when I am in vnc session to a Linux Box without X11 graphics enabled. Out of 20 runs of the software on an average 1 run fails to bring up the GUI in two different ways, The GUI shrinks to a small square. The GUI doesn't appear at all. ...

How can I correctly calculate the height of a jTable row to ensure that the contained jLabel containing HTML is entirely displayed?

Hello, I have a JTable instance, containing a number of rows. The columns in this table are JLabel instances containing an HTML-formatted string. One of my requirements is that all the data in these columns should be displayed. If the column width (for whatever reason) is not wide enough to display all the data, the text should wrap on...