swing

How do I set the position of the mouse in Java?

I'm doing some Swing GUI work with Java, and I think my question is fairly straightforward; How does one set the position of the mouse? ...

how to display a image in java application

i want to display a image in my java application. i found a code to download the image from the webserver. what that code do is it takes the image and show it in the jframe. i want to use a label to show the image or soemthing else. so i can put it in my java application. can someone help me. it shouldnt be JFrame please help me here...

Accordion for Swing?

What component libraries for Swing offer an accordion widget? I found JIDE, what are the other options? Any free ones? ...

Zoom in Java Swing application

Hi there, I am looking for ways to zoom in a Java Swing application. That means that I would like to resize all components in a given JPanel by a given factor as if I would take an screenshot of the UI and just applied an "Image scale" operation. The font size as well as the size of checkboxes, textboxes, cursors etc. has to be adjusted...

how to display a image in java application after downloading the image

i want to display a image after downloading that image from a web-server i have wrote the code for downloading the image. but i cant set it up to a label or any thing other than jframe (because i want to add more buttons and labels to the GUI). here is the code to download the image from the webserver. now i want to set it to a label....

Transarent background over heavyweight components

I've got a problem. In LayeredPane I have 2 components: heavyweight coponent and JComponent(or any other what I could draw text in) that is placed above the first one. I'd like JComponent to have transparent background, but it has black background. Heavyweight coponent is a component that renders video and JComponent is component what I ...

setCursor on container without it changing cursor of sub components

JPanel panel = new JPanel(null); panel.setSize(400, 400); panel.add(new JButton("Test")); panel.setCursor(Cursor.getCursor(Cursor.SOMETHING_SOMETHING_CURSOR)); The panel will have a custom cursor, but I don't want the button to have a custom cursor. I don't want to have to set the cursor of every sub component, because in my applicatio...

How to change time format in swing

Hi all, I am using swing framework and applets. If I take locale as en_US, the time shows in AM and PM. If I take Locale as ms_MY, the time shows in Pagi and patang. How can I show time in AM and PM when using locale ms_MY? Please help me ...

How to make items fill available space in JToolBar?

I have a horizontal JToolbar with JToggleButtons. For some reason it is placed in a container that has larger height. My JToggleButtons use only as much space as they need, leaving ugly empty space below and under them. How can I make them fill all available space without setting size arbitrarily? Similar question: How I can make compon...

Initial state of autoCreateRowSorter in Swing JTable

I have this JTable on my Swing app with the autoCreateRowSorter enabled. My table only has 3 columns, two strings and one int, it works well for all of them when I click the column headers. However, I'm looking for way to do it programatically. I wanted to set the "initial state" for this table. With the Windows look and feel, the colum...

Extending a Java Swing class in Clojure

I'm trying to extend a Java Swing component in Clojure, i.e. I want to extend a javax.swing.JComponent and add some custom methods implemented in pure Clojure in addition to all the standard inherited methods. I've tried using "proxy" which works great if I just want a single instance (in the same way as an anonymous inner class). Howev...

How to get JTree expanded?

I have a wizard with several screens where user has to fill his/her details for further processing. At the second screen I have a radio group with three radio buttons that enable additional elements. To proceed, user has to choose one of them. When user selects third button, single-selection JTree filled in with data enables and user has...

Laying out JPanels to make a simple GUI

Hello, first of all, this is more or less my first GUI and ive learned Java for not more then a week, so it might contain some serious programming errors. What i have right now is: Buttons and labels are part of OptionPanel and are on the left, DrawingPanel is about 5x5 px in size and is on the right. What I am trying to do is a simpl...

Is there a Swing JPanel toolbar background that fits all OSs?

I'm using a JToolBar to have a toolbar on my application, but I don't like the look of it. Actually, there's basically no look, no background and the buttons are flat when the mouse is not over them. This is on Windows. How can I have a better look for this? Something that would fit better on Windows? Maybe something like the ToolStrip ...

JPopupMenu should not lose focus

Hello everyone, Question about JPopupMenu behavior. I would like the JPopupMenu not to loose focus when it comes up. Also when JPopupMenu is in focus, the user should be able to click/update other parts of the Applet. Is this possible? Reason is that this JPopupMenu is displaying some codes and it needs to be kept open for reference....

Dynamic Clock in java

I want to implement a clock within my program to diusplay the date and time while the program is running. I have looked into the getCurrentTime() method and Timers but none of them seem to do what I would like. The problem is I can get the current time when the program loads but it never updates. Any suggestions on something to look in...

Add other components to JFrame with background

Hello, I want to add a background image to my JFrame but when I do it using the code below, I'm unable to add other elements like JLabel or JTextField. ImageIcon icon = new ImageIcon("src/images/back.jpg"); backImage = icon.getImage(); BackgroundImagePanel contentPane = new BackgroundImagePanel(); contentPane.setBackgroundImage(backIma...

Getting an action after text is pasted into a JTextComponent (Java)

This really puzzles me. I have a JTextComponent for which I've added a right-click cut\copy\paste menu using a JPopupMenu and DefaultEditorKit.Cut\Copy\PasteAction(). JMenuItem cutItem = new JMenuItem(new DefaultEditorKit.CutAction()); JMenuItem copyItem = new JMenuItem(new DefaultEditorKit.CopyAction()); JMenuItem pasteItem = new JM...

Problem painting JPanel gradient background with a JLabel on it

I have the following code to paint a JPanel's background: @Override public void paintComponent(Graphics g) { UIDefaults uid = UIManager.getDefaults(); Graphics2D g2d = (Graphics2D)g; Dimension d = this.getSize(); g2d.setPaint(new GradientPaint(0, 0, uid.getColor("ToolBar.light"), 0, d.height, uid.getColor("ToolBar.shad...

Jlabel with alpha value

Hi: i have jLabel and i want to change its opacity (alpha value) each one second , i tried something like that but its not change each one second , jlable change its opacity only with last alpha value . Color color = jLabel1.getBackground(); int alpha = 255; long initTime = System.currentTimeMillis(); while(true){ ...