swing

Alternative options for displaying video in Java?

At the moment I use QuickTime for Java to display video in a swing application. However, Apple has deprecated support for QTJava and I was wondering what options other are available right now+ for moving forward? Requirements: Must be cross platform (WIN & OSX). Must be able to support many different video formats. Must be capable of ...

Scatter Graph with multiple "scatter lines"

Ok, I know about JFreeChart and others, but I'm coding my own simple scatter graph. I've already got a box chart down (without y-axis labels but that shouldn't be a huge problem when I explain it in my report). I've got a basic scatter graph class, however I've tried to change it so that I can add in different scatter values. It works,...

[Java - Swing] Image slider

I want to create something like this http://flowplayer.org/tools/demos/scrollable/index.html but in Java Swing. I dont need all those effects, just scrolling of thumbnail images. Is good aproach to use toolbar and ImageIcons, and then on click load image on some JPanel. Is there any common practice for this ? ...

Press [X] button to close JFrame won't invoke dispose method

I have set up a JFrame like this: public class XFrame extends JFrame { public XFrame() { setSize(100, 100); } @Override public void dispose() { super.dispose(); System.out.println("Dispose get called"); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { ...

How can I create a "Drop-Down" menu in a Java Swing toolbar?

I've created a drop-down menu on my Swing JToolBar. But it doesn't create behave the way I want. I'm aiming for it to work like Firefox's "Smart Bookmarks" button. It disappears when the user selects a menu item: CORRECT! It disappears when the user presses ESC: CORRECT! It disappears when the user clicks somewhere in the main frame o...

Resize JScrollPane client without scrollbars rolling

I have a JScrollpane which contains a scrollable client that changes its size dynamically while using the application. I want the JScrollPane to be aware of the changes without moving the viewport when the client size changes. To clarify what I mean: Refer to the Java Webstart example ScrollDemo2 from the article How to use scroll panes...

Java Swing: Different TableCellRenderers

Hi! Given a javax.swing.table.TableColumn... is it possible in some way to specify the TableCellRenderer/TableCellEditor to be used for a given type rather than having the TableColumn use the same TableCellRenderer/TableCellEditor? I'm aware that I can specify some DefaultCellEditor/Renderer in the JTable, but this is not what I want. ...

Show/Hide JMenuItems in a JPopupMenu based on a JTree's selection.

I have a JTree which displays a JPopupMenu when I right click nodes in the JTree. What is the best way to hide/show or enable/disable certain JMenuItems in my JPopupMenu based on the node selected in the JTree? The first solution that came to mind was to add a TreeSelectionListener to the JTree for the 'value changed' event. In the even...

Animated Swing effect to display full-resolution image

I've got an editor with lots of image thumbnails. I'd like a double-click on an image to display the full resolution image using a modal undecorated dialog. Ideally, this would be animated, to show the image zooming up to full resolution on the center of the screen, then any click would make the image go away, either zooming back out o...

Implementation of file "save" like Notepad

Hi Experts, I want to create a text editor (using java/swing) like notepad. For this I need the implementation of saving file. mean if the user clicks on "save" first time then the dialog should appear for taking file-name, file-extension. But if he clicks again on same "save" button then the file should save without appearing the "save...

private javax.swing.JTextField3; error

I greatly thanks those that reply to my question "main method not found error", after correcting all the parenthesis and it seem the code is alright.On the IDE its still indicate the error below; private javax.swing.JButton jButton1; private javax.swing.JComboBox jComboBox1; private javax.swing.JLa...

Using a JFrame's focus (being lost) to stop recording a screen cast?

Hello, In my Swing application, I'm using a custom module to record a screen cast. However, I'm a bit hung up on when to force the recording to stop. Right now, I check to see if the user still wishes to record (meaning that they haven't clicked the 'stop' button) and if the application is still open (closing the application causes the...

How can I change the size of frame?

I have a frame which has a menu item for choosing the font and its size, when the user choose her/his font size, all the text of buttons, panels, which are in my program (has many frames) will be changed but they will be bigger than the size of frames. What should I do for changing the size of my frames at run-time? Edit: Also with usin...

Setting a button

I have 2 buttons. One is "add". The other is "cancel". In the cancel button action, I want to write that until the add method is not called, this button do nothing. How can I do that? ...

How can I refresh a JTree after adding some nodes to the underlying model?

First of all, let me say that I dont use the DefaultTreeModel. I implement my own TreeModel, so i cant use the DefaultXXX stuff. The problem is this: Through some addStuff() methods which my model defines I add nodes to the underlying data structure. I then notify listeners by calling treeNodesChanged() inside the addStuff() function (I ...

ActionListener as key binding

I am in a situation where i have a class, ActionFactory that produces ActionListener s to be used in menu items and buttons. Now i want to bind some of these actions to keys. KeyStroke controlS = KeyStroke.getKeyStroke (KeyEvent.VK_S,modifierKey,false); panel.getInputMap (JComponent.WHEN_IN_FOCUSED_WINDOW).put(c...

How to receive key events during a drag&drop?

Hi there, I'm currently trying to receive key events during a drag and drop, but it seems to me that the focus is taken away while dragging so that I can't listen to any key events. I'm dragging a JComponent subclass that implements KeyListener and requests the focus in the DragSourceListener's dragEnter method, but my assumption is th...

Small dot trailing cursor in Swing application

There is a small dot that keeps trailing the cursor on a Swing application as I move the cursor about over the application frame. What is causing this? ...

Creating Dynamic JTrees (Controlling Root Node Visibility)

I have a question about how to dynamically generate JTrees. Is there a way to set the Root Node invisible without making its children invisible too? I have tried to do the following but it shows all nodes as invisible. Keep in mind that I want to add and remove children of the Root Node at any point in time. I've added comments so you ca...

Hide a button from Layout in Java Swing

Hi, I am trying something very basic: I have a list of 5 buttons. They are in a FlowLayout and the general idea should be that once I click one it should disappear and the others should reorder themselves accordingly. Now, if I call setVisible(false) the button becomes invisible, but it still occupies it's space in the Layoutmanager. ...