swing

How do I create a right click context menu in Java Swing?

I'm working on a school project and we want to implement a right click pop-up menu in the gui. Currently we are doing something like creating a JMenu on right click and setting its location to that of the mouse's position... This seems really ugly and is very buggy, is there any better way of doing this? I'm sure there must be. ...

Is there a Swing hack to query or set Z-order of a window?

We are trying to save the state of the application on exit and restore it on startup. Part of the state is the relative Z-order of all JFrames. Unfortunately, Swing doesn't seem to provide any method to learn or set Z-order of a Window (even relative to other windows in the same VM). We deal with setting the Z-order by calling toFron...

Problem in printing Jpanel Data

I am working on a swings application I have a Jpanel, I am facing serious problem with printing this JPanel data with "card printer". This is working fine when i using paper color printer but when i am using card printer its printing nothing. I have tested the printer using some Images and it is printing fine when i print any Image direc...

In Swing use an InputVerifier to check dates and time

I'm currently working on a Swing app and I've got a few JTextAreas that are going to be parsed, turned into dates and then added to a MySQL database. One is a Date field, the others are DateTime, what I'm trying to do is use InputVerifier to make sure they're entered correctly. I've created an InputVerifier that tries to turn the text i...

Containing drawing to a panel area

I want to draw an array of X and Y integers to a panel in a Java frame. What is the best way to draw the line (currently I'm using Graphic's drawPolyline)? How can I efficiently scale the integer values so they all fit in the panel area without knowing the max (Y) value? Update, for example public void paint(Graphics g) { int heigh...

How to make canvas with Swing?

Hi, I'm trying to make a paint editor with Java in which I have a toolbar with the objects that I would like to paste in the canvas. I'm using swing components to make the GUI, but when I looked for the way of making the canvas, I only found the class canvas from awt. Is there any way to make something similar to canvas with swing? (f...

Jpanel Printing Please Someone Help

I am using PersonaC30 card printer to print my Jpanel data on card. My print method is working fine with paper printer but when i print with card printer its not printing my data. Although its printing well externally but its not working with my application please someone help me out if any of you have work with card printing i am trying...

Example of Jasper Reports in Swing Application using Web Start

How do I use Jasper Reports in a Swing application using Web Start? ...

make a button round

hi, im trying to make a JButton round at the (x,y) corrds of (150,210). i want the button to be an oval of the size (40,40). and the buttons background color red. it doesnt need text so i should get a button to what ever size i want right. i am using a panel and i set the setLayout to null setLayout(null) i checked google and it brou...

How would i program a dynamic menubar in Swing?

Basically i want to be able to allow the user to save bookmarks which are then put into a list on a submenu on a menubar. How would i go about programming a general function for any number of bookmarks that may be added, i basically want the items to put the URL into a textbox when clicked. Would i need to create a new class for this, or...

Dragging handle in Java Swing

I can't seem to figure out how to make a resize drag handle in Java Swing. If you're not sure what I mean, open up the "Ask Question" page on this website and look at the bottom of the text area. It has a bar which you can drag in order to change the size of the area. I'm looking for a way to do this in Java Swing. I don't even know wher...

Can a text widget show overflow with the "..." in the middle of the text instead of the end?

I have a JComboBox which contains an MRU list combo-box and a for a directory tree panel. Together, the two form the left hand panel of my GUI (the MRU is above the tree panel) which is a JSplitPane, so the left panel is resizeable. It has a problem in that the directory text is always longer than the required width to see that directo...

Binding an EditorKit to a specific document model for a JTextPane

I can't seem to figure out a way for an editor kit to work for only one JTextPane. Every time I implement one, it always functions for any JTextPane in the frame. How can I fix this? ...

Java - How to create a custom dialog box?

I have a button on a JFrame that when clicked I want a dialog box to popup with multiple text areas for user input. I have been looking all around to try to figure out how to do this but I keep on getting more confused. Can anyone help? ...

How should I handle exceptions when using SwingWorker?

I use SwingWorker in Java 6 to avoid running long-running code on the event dispatch thread. If the call to get() in my done() method returns an exception, what is an appropriate way of handling the exception? I'm particularly concerned about possible InterruptedExceptions. The JavaDoc example simply ignores the exception but I've lear...

how to get the PageFormat from a Java.awt.print.PrinterJob

Hi, I'm trying to use the PageFormat information to modify my javax.swing based printout prior to printing it. I am stumped as to how I can get the PageFormat from the PrintJob (which is obtained using getPrinterJob() and printDialog()). I know there is the getPageFormat method, but I can't figure out how to get the PrintRequestAttribu...

Problem with inserting rows into JTable

Hello people. I have problems on inserting rows into a JTable and I don't know what the problem is. I do exactly like this: ((DefaultTableModel)myJTable.getModel()).insertRow(0,webSiteDownloader.getWebSites().toArray()); The webSiteDownloader is one object that have an ArrayList. I can get that array calling the method getWebSites. ...

How do I add a file browser inside my Java application?

I am new to Java progamming and am building a application that will add, display and remove files from a given folder location. I have added files using JFileChooser and know how to delete the files. However I am stuck with the display portion. I want to display the files and folder using different icon inside my application. I tried t...

How can the disable file operation, file selection and filter panel from JFileChooser(JAVA Swing)?

I need to embed JFilceChooser dialogbox in a Panel. I only need the file and folder view. How can i disable others panel that are included in dialogBox i.e(file operation, file selection and filter panel) from JFileChooser() dialogBox.. Thank you ...

Hide print dialog

Hi, I am printing a Jpanel and its working fine, but now I need the print dialog box, which always appear when the print button is clicked. It suppose to go like, when user press print button the default printer should start printing the job with out coming up with a print dialog box. Here is the code, I am using, Paper paper = new Pape...