swing

Why do the JButton in my dialog look weird

I'm fairly new to Java Swing/AWT et al and hence the question. I have a simple dialog with some text and a couple JButton. I am using the GridbagLayout for this dialog. But when I look at the dialog, the JButtons are kind of having a weird shape and I cannot seem to right justify the text either. Is this a limitation of the Layout I ...

How to deactivate focus rects on one component in Swing/Nimbus

Hi everyone! For my current project, i'm using Swing and the Nimbus look and feel. The look and feel draws focus rects that look great on buttons, text fields and so on. Unfortunately, a focus rect is also drawn on any tab of a TabbedPane. How can i deactivate drawing the focus rect around those tabs? Thanks in advance, David ...

Intersecting rectangles

This is an analytical geometry kind of question.I am not sure I can post it here.However I have to come up with a Java function to do this functionality.I have multiple rectangles in a page/swing container.I know the bounds of the rectangles.Now I need to find which rectangles are intersecting each other.One good thing here intersecting ...

Socket using in a swing applet

Hi,I should made a server & client in Java,based on Swing and gui.I neeed to make somehow a socket that will go from the server to the client and from the client to the server, and will pass some kind of a string.I would like to have later a function that would do several things according to the string that would be in the socket. For so...

Jpanel with multiple images - Memory Usage

Hello, Some time ago I made the following question about placing multiple images in a JFrame: http://stackoverflow.com/questions/2155596/can-i-create-a-jframe-with-multiple-images. The problem is: When I'm mooving the scrollbar to see the images, I figured out that it consumes a lot of memory (about 1mb each scroll roll for the entire f...

non-destructive transformations on java2d objects

I would like to be able to zoom and unzoom on a Java2D scene made of Path2D.Double without thickening the lines, just by dilating the distances. I'v tried to apply a transformation to the Graphics2D object the paintComponent method receives, but this makes the lines thicker. The only way I found was to apply a transformation to the lin...

Java Swing Run program when Windows startup

Is there possible to code the Java Swing application to run when Windows start up? ...

JCheckboxMenuItem not working as expected.

I have create a popup menu and on right click in a panel the menu is displayed. But when i click the menu item the checkbox doesnt get selected. Here is the code: public class DebugMenu extends JPopupMenu implements ActionListener{ public void actionPerformed(ActionEvent e) { System.out.println("inside action"); AbstractButt...

Creating a custom modal dialog for a Swing applet / application

I'm writing a Swing application that needs to function either as an applet in a browser or as a standalone application, i.e. it may be contained in either a JFrame or a JApplet. In this context, I'd like to display a custom modal dialog box to the user (i.e. a complex dialog with a custom layout and logic, not just one of the simple JOp...

How do i select a character in a textfield?

is it possible to select a certain character from a textfield ? Is it possible to switch their position as well? e.g. Hello is it possible to switch the position of the "H" with the "e" ? to make it "eHllo" ? ...

Is the adapter pattern usable in cases where the different interface methods have varying parameters

I am creating a client side swing app that will have data provided by/from one of many data providers(brokers). The data providers however, have varying ways of perfoming same things e.g. broker1's login method public boolean doLogin(String username, String password); broker2's login method public int login(String username, String p...

How to make the jList selectable inside a jTable.

How to make the jList selectable and jScrollPane scrollable inside a jTable. This is my table code : private JTable getCalendarTable() { if (calendarTable == null) { calendarTable = new JTable() { public boolean isCellEditable(int nRow, int nCol) { if (nRow % 2 != 0) { return ...

How do I stop my JTextPane swallowing keyboard shortcuts (accelerators)?

My application's main JFrame contains a JTextPane. While it has focus, it consumes all keyboard shortcuts ("accelerators") instead of passing them on to the JFrame's JMenu. This means that while it has focus, eg ctrl-n for "New Document" doesn't work. Obviously it's useful that it handles ctrl-A/C/V/X correctly for select all/copy/paste...

How to upload multiple files using Swings Applications?

I m trying to upload multiple files in swings applications.I have declared an array to hold the values of selected files but when i click on upload button only 1 file is getting uploaded. How can i upload all selected files into database? The code to Open and Upload File is .... public void openFile() { JFileChooser jfc = new ...

JComboBox in a JTable cell

Hello... I have a JTable created using a model, which is based on a matrix of objects. For each row, I want to put in a specific column (the 5th) some information using a JComboBox. I have tried the following: for(int i=0; i < n ; i++) { ..... data[i][5] = new JComboBox(aux); // aux is a Vector of elements I wanna insert } ta...

JTextFields on top of active drawing on JPanel, threading problems.

Dear developers, Has anyone ever tried to use Swing to construct a proper multi-buffered rendering environment on top of which Swing user interface elements can be added? In this case I have an animating red rectangle drawn onto a background. The background does not need to be updated every frame so I render it onto a BufferedImage an...

java applet buttons

OK so I have this applet thats like this BorderLayout.CENTER - (Within this is JPanel) BorderLayout.EAST - (Within this is a new GridLayout (4,5) BorderLayout.SOUTH - (Within this is a TextArea) Anyway, on the applet, I have to HOVER over the buttons to see them. They don't paint there I guess but I'm adding them in the init() metho...

what is "?????" is in windowClosing(WindowEvent e)?

public void windowClosing(WindowEvent e) { if(e.getSource() == getFrame().?????) { //System.exit(0); } else { // do something another; } } what I want to ask is what the "?????" is?get windows' what? ...

JCheckbox as indicator?

I need an off/on indicator for a panel in my Swing application. My gut reaction is to try to use a JCheckbox, and somehow disable the mouse input and change the checkbox state only through my program. But a radio button would look better. Is this the best way to do so (& if so, how to disable mouse input w/o making the control look dis...

How to check for the latest version of java

I want to make a java-based GUI tool that checks for the latest version of java available online,and compares it to the version currently installed I already know how to check for the version currently installed on the machine I don't know about the part where you check for the version available online ...