Yahoo Québec Recherche sur tout le Web

Résultats de recherche

  1. I have a JPanel to which I'd like to add JPEG and PNG images that I generate on the fly. All the examples I've seen so far in the Swing Tutorials, specially in the Swing examples use ImageIcons.

  2. All you have to do is to add this code after initComponents (); getContentPane ().setBackground (new java.awt.Color (204, 166, 166)); That is an example RGB color, you can replace that with your desired color. If you dont know the codes of RGB colors, please search on internet... there are a lot of sites that provide custom colors like this.

  3. 19 févr. 2014 · For generating click event programmatically, you can use doClick () method of JButton: b.doClick (); The actionPerformed method is used when a button is clicked normally. If you want to do some fancy interaction with the button you can also use other events like mousePressed in the MouseListener.

  4. In general, using pack is preferable to calling setSize, since pack leaves the frame layout manager in charge of the frame size, and layout managers are good at adjusting to platform dependencies and other factors that affect component size. From Java tutorial.

  5. 27 janv. 2012 · 3. Using EXIT_ON_CLOSE will forcibly terminate the application. If you need to take action before the program exits (such as saving working data), then you have to tap into the JVM event handlers instead of just using the normal swing event handlers.

  6. 21 mai 2019 · If you have an java.awt.Image, resizing it doesn't require any additional libraries. Just do: Image newImage = yourImage.getScaledInstance(newWidth, newHeight, Image.SCALE_DEFAULT); Obviously, replace newWidth and newHeight with the dimensions of the specified image. Notice the last parameter: it tells the runtime the algorithm you want to use ...

  7. 23 avr. 2009 · Generally, SwingWorker is used to perform long-running tasks in Swing. Running long-running tasks on the Event Dispatch Thread (EDT) can cause the GUI to lock up, so one of the things which were done is to use SwingUtilities.invokeLater and invokeAndWait which keeps the GUI responsive by which prioritizing the other AWT events before running the desired task (in the form of a Runnable).

  8. 28 sept. 2008 · From this link. If you are using Java 1.4 or newer, you can use the simple method setLocationRelativeTo (null) on the dialog box, frame, or window to center it. As @kleopatra said on another answer, setLocationRelativeTo (null) has to be called after pack () in order to work.

  9. 13 mai 2015 · Creating a new GUI in Java (1.8) Swing, I am searching for a way to override resize behavior of all my components. Let me explain to you with some edited photos: 1. Full Screen GUI. This is my full screen GUI, with 3 panels and a JToolBar. The green one needs to have a fixed size, the others would be resizable.

  10. Open your Java source code document and navigate to the JTable object you have created inside of your Swing class. Create a new TableModel object that holds a DatePickerTable. You must create the DatePickerTable with a range of date values in MMDDYYYY format.