swing

Does anyone have a example of slot machine in Java using swing?

Hi Everyone, I want to get some examples about the GUI of an slot machine written in java, I know that it's kind of specific thing, but i want to know if it's possible to do some animations with java swing, or something like that, greetings ...

JTable adjust column and row width according to Data

I need to show the below data in a Jtable cell.As of now everything comes in a single line even-though i'm overriding the object's toString method with newline characters.How can I set the Jtable to adjust the cell height and width depending on the data. Segment ID: 1 Elevation : 2.0 Azimuth :30.0 ...

Java Swing JTable; Right Click Menu (How do I get it to "select" aka highlight the row)

Hi all. Short: I need a "right-click event" to highlight the cell row. I am using a JTable inside a ScrollPane in Java Swing (Netbeans Matisse). I have a MouseClicked event listener on the JTable that does the following: if (evt.getButton() == java.awt.event.MouseEvent.BUTTON3) { System.out.println("Right Click"); ...

Detecting where a change event came from

I have a bunch of JTextComponents that fire update events to a common model. The model then fires out change events to the other components so they can all be in synch. How can I detect which one fired the event initially so as not to fire the event back? I ask this as I'm currently getting an expection due to attemtping to update the...

How to create Swing OSGi bundles on AWT EventQueue with Spring DM

I have an OSGi target platform consisting of Equinox, the Spring Framework, Spring DM, and several custom bundles for my application. All of my bundles contain Spring application contexts and so are automatically loaded by the Spring OSGi extender. Some of my bundles contain Swing ui components. The problem is that the Spring OSGi Exten...

Date time picker inside JTable

Is it possible to add a DateTimePicker to a JTable Cell.A particular column should be updated with date and time..Is it possible to add such a component to a JTable ...

Does not preserve the value of cell

Posted CellEditor. import java.awt.Component; import javax.swing.AbstractCellEditor; import javax.swing.JComponent; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.table.TableCellEditor; public class UserCellEditor extends AbstractCellEditor implements TableCellEditor { JCo...

How to adjust components and JTable in a JFrame dynamically?

When i try to hide the rows in a jTable, the jTable ScrollPanel need to adjust its size to remaining rows and, other components in the Frame also adjust to the change. i.e., there shouldn't be any space between the components and the jTable after hiding the table-rows.. ex: in microsoft excel, when we delete a row, the remaining rows w...

Do you have to change Java Swing code generated by Eclipse VE for a correct program?

Using the Visual Editor in Eclipse I started a Swing UI containing a table (JTable) with 2 columns (JTableColumn). Adding data to the table this way: final DefaultTableModel model = (DefaultTableModel) this.jTable.getModel(); model.addRow(new Object[] {"Column 1", "Column 2"}); generated an ArrayIndexOutOfBoundsException. I solved thi...

Displaying a JComponent inside a JPanel on a JFrame

I am failing to display a JComponent inside a JPanel on a JFrame. The following does not work. JComponent component = ... panel.add(component, BorderLayout.CENTER); frame.add(panel, BorderLayout.CENTER); But if I add the JComponent to the JFrame[like frame.add(component, BorderLayout.CENTER);], it displays the contents. Any ideas ...

Swing - Methods and attributes of an extended JPanel class inaccessible from JFrame

Hi there, I am working on a project where I have a class called HGraphic that extends JPanel. This class has a public method called updateNum that receives an integer as a parameter and does some work with it, updating some elements. This HGprahic class has an instance in the main class of my project (the main class extends JFrame)... ...

Swing and lazy loading components

I have used the Eclipse plugin Visual Editor to construct Java Swing interfaces. As I'm not a big fan of the code WYSIWYG (UI) editors generate, I wanted to optimize it, when I noticed, that the editor implemented all elements using lazy loading like this: private JPanel getSomePanel () { if ( somePanel == null ) { someP...

convert awt to swing automatically

From what I know and have been reading, converting from awt to swing seems to be quite mechanical. With the exception of the different threading model, most of swing components generally map well with the awt ones. Was looking for a tool to do this conversion automatically. Understandably, this may not be a 100% conversion, but at least...

Java: apple.awt.CToolkit keeps pumping out errors randomly

I've been developing an application in Java for quite some time now on my Windows and Linux machines but just recently switched over to my new MacBook Pro that has the latest (JRE 1.6 update 20) installed on it. I just started noticing while testing out the various features of the application that it gives errors randomly when interactin...

Swing: show accelerator in tooltip

How do I make a tooltip of a toolbar button (which is based on the same Action as a menu item) show the accelerator at the right? ...

Software-Design Issues

Hi, I'm planing to build a software in client-server-design. Technology should be Java. Server should have a communication layer for web-services (e.g. RESTful Jersey), RMI, JSF. Clients can be: Fatclients in Swing or Browser clients in JSF. In my focus are JBoss Netty for the server, Jersey looks much more simple but Netty would have...

BorderLayout: Nested CENTER Panel Grows But does Not Resize Outer Panel

I have a main JPanel which implements Scrollable and uses a BorderLayout. It contains one NORTH readonly JEditorPane, one CENTER JPanel with a FlowLayout whereby JButtons are added dynamically, and one SOUTH JLabel, all added in that order. When many JButtons are added to the CENTER JPanel, the buttons wrap onto the next rows: the prob...

Stopping GroupLayout components from stretching vertically

Is there an easy way to get all (or most) of the components in a GroupLayout application NOT stretch vertically? I know I can do it by forcing each component to it's preferred size when I add it, but that makes the code so much more verbose: .addGroup(layout.createSequentialGroup() .addComponent(oDevRadio) .a...

JComboBox and vetoableChange?

When a user changes the value in a JComboBox, I want to prompt them to confirm the change. If they say "no," the old value will remain. If they say "yes," the new value will be selected. I tried adding a VetoableChangeListener to the combobox, but this does not ever seem to be fired! Per the JavaDoc for JComponent.addVetoableList...

Custom JComponent with embedded Swing components not positioned in exported image.

I have a funny problem trying to export custom Java JPanels to a PNG file. The export process of the components I've been writing up until now have worked flawlessly. My JPanels include custom-written JComponents (e.g., override paintComponent(Graphics g) and write what I have to). The export process looks like the following (of the e...