swing

How to disable scrolling from mouse wheel in a JScrollPane header ?

Hello, I am currently working on a SWING frame with a JScrollPane (including a JComponent), with a row header and a column header (which are also JComponents). When the mouse is over the JComponent or one of these 2 headers, mouse wheel provokes scrolling. What I want to do is to disable this scrolling when the mouse is over the column...

Java - updating textFields from JList

I am making an address book GUI with Java and I have a JList that displays all the names of the people in my ArrayList (this is populated by the updateinfo method mentioned below). I want it so when I click an item on the JList, the TextFields are then updated with that persons details. Before I have only used buttons and therefore actio...

Drag & drop with JLabel

Hi, Can I drag a JLabel and insert into it a custom object or should I use another component? But I have to use TransferHandler with exportAsDrag. My code: final JLabel label1 = new JLabel("Drag here"); Collection<Person> person= new ArrayList<Person>(); //Register transferhandler objects on them label1 transfer itss //foreground col...

JComboBox "no text" text

I'm trying to reproduce the behavior of the search field of Firefox or Safari, or the search field of stackoverflow.com on the top right of this page. I mean, when there is no text on the editable JComboBox, an instruction text is displayed, like "Type here" or whatever. When the JComboBox is focused the text is removed. If the focus is...

Digital or LCD-like display class?

I remember seeing a tutorial on Sun's site that had a class for a digital-like display, but I can no longer find it. How would you make numbers appear like a digital clock, using Swing? ...

Require help to implement drag from Java Application and drop to Native File System

I have a Java Swing application which shows a list of the files/Folders that have been uploaded to the server. I have a requirement to download selected file(s)/folder(s) to native file system using Drag and Drop . I have searched links but almost every link describes the Drag and Drop within a Java Swing application. My requirement is t...

Cannot display image on Jpanel

I'm using the Netbeans GUI builder, but it's a little confusing now. How can I add an image to a panel? I think i'm doing it correct, but it's not showing up. I think it should be in the init() method, but netbeans does not allow me to change that part of the code. This is the code I added for the image: //these four lines I added to...

Elements not adding to JList

For some reason, I can't add anything to my JList. The JList is visible but simply shows white - nothing can be selected. List list; DefaultListModel listModel; //... list = new JList(); list.setBounds(220,20,150,200); listModel = new DefaultListModel(); listModel.addElement("ONE"); panel.add(list); Am I missing something? ...

Java change label text from another frame

I'm writing a server/client program. In the server, when I click a button some infomations will be sent to client and show on a jLabel. But the problem is when the client get focus, it loses all the informations recieved. Somebody help me please!!! ...

Java swing. How to wait for other Jframes

In a JFrame, when I click on 'login', I pop up another Jframe which is the login window. How do I make my main Jframe wait for my login Jframe to exit, before doing anything else? ...

Java help. How to draw images

Hi I'm starting to work on this project where I need to have a picture (map of the US) and then I need to circles of different sizes on the map at different locations. Something like this: http://www.npr.org/templates/story/story.php?storyId=110997398 What's the best way to go about doing it? I've never dealt with Java 2-d but I'm guess...

Swing Timer expires earlier than expected

I have a module that sets Swing Timer to wake up after 3 minutes and I see that it is fired after less than 2 minutes. I have to mention that while waiting for the Timer, an extensive Swing activities went on and other Swing Timers, on different threads were used. Could such activity affect the Timer's timing? ...

Importing a file using the Java FileChooser

Hi I'm having trouble using the Java JFileChooser and was wondering if anyone could help me out. It's probably something really simple but I just cant spot whats wrong. The JFileChooser window opens fine when I click my import button and I can navigate to any field but I just cant read them into my JTextFields. Heres my JFileChooser m...

Find out if JList has an item currently selected.

I have a JList which is populated after importing a file. Is it possible to have the first item/element of the JList highlighted/selected. I have browsed many places hoping to find a line along the lines of list.setFocus(0); //or listSelectionEvent.setSelection(0); //0 referring to index point of the list Maybe this isn't even possibl...

Java compiler error. Cannot find symbol

Why am I getting this error when the SystemController class is in the same directory? sgs$ javac Main.java Main.java:27: cannot find symbol symbol : class SystemController location: class sgs.Main SystemController sc = new SystemController(); ^ Main.java:27: cannot find symbol symbol : class SystemController location...

how to use java jar in c/c++?

i am a new developer of java swing. i want to pack the GUI program. With the help of neatbeans, i get a file of java jar. But i want to convert the jar to exe file, although i know exe4j, but i need the exe file include the jar and other files. Maybe using jar in c/c++ is a solution ? ...

Java Swing questions regarding GridLayout and paintComponent methods

Within this program, we need to create an 8x8 grid of "LifeCell" widgets. The instructor did not mention that the widgets had to be an object of Shape so I went ahead and used the GridLayout class. The GridLayout class works fine (as well as I know, since there is no visual aid to confirm.) The object of the program is to play the Game o...

When i import from a file, click the next and previous buttons it is exporting data to my file? is there something wrong with my action listeners?

public AddressBookApp(){ frame = new JFrame("Address Book"); frame.setSize(500, 400); frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); panel = new JPanel(); panel.setBackground(Color.gray); panel.setLayout(null); frame.add(panel); frame.setVisible(true); JMenuBar menubar = new JMenuBar(); frame.setJMenuBar(menubar); JM...

Using maven to distribute a swing application that can have each dependency individually tracked

I'm moving my project to Maven and eventually OSGi. I currently distribute the project is a large Zip file with all the dependencies. Although my projects code is only 20% of the total package I have to redistribute all the dependency. With smaller independent modules this may be even less. Looking here on stack overflow it seems that t...

How to use Windows 7 Jump Lists in a Java Desktop app?

As the title suggests, we have a Java (Swing) desktop application, and we'd like to be able to have some basic access to the Jump Lists (in the new Windows 7 taskbar). In particular, we'd like to be able to add some "user tasks" to the jump list--the ability to start other modules in our application, maybe to close all running modules, ...