Customize JOptionPane Dialog

You can simply add your components to a JPanel and then add this JPanel to your JOptionPane, as shown in this small example : import java.awt.*; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import javax.swing.*; import javax.imageio.ImageIO; public class JOptionPaneExample { private void displayGUI() { JOptionPane.showConfirmDialog(null, getPanel(), “JOptionPane Example : “, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); } private JPanel … Read more

How to get Icon from JTable

I can’t resist just example for that import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.EventQueue; import javax.swing.*; import javax.swing.table.*; public class TableIcon extends JFrame implements Runnable { private static final long serialVersionUID = 1L; private JTable table; private JLabel myLabel = new JLabel(“waiting”); private int pHeight = 40; private boolean runProcess = true; private int count = … Read more

C# console application icon

You can change it in the project properties. See this Stack Overflow article: Is it possible to change a console window’s icon from .net? To summarize right click on your project (not the solution) in Visual Studio and select properties. At the bottom of the “Application” tab there is a section for “Icon and manifest” … Read more

Spring behavior simulation

Here’s a working sscce using FloatSpring. import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.AbstractAction; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.Timer; import javax.swing.UIManager; /** * @see http://stackoverflow.com/a/11233735/230513 */ public class Test { private static Spring spring = new Spring(); public static void main(String[] args) { EventQueue.invokeLater(new … Read more

Java GIF animation not repainting correctly

Okay, so after much mucking about, I was able to, finally, change the disposal method for the frame to restoreToBackgroundColor. Basically, what this means is that the animation is not an incremental change, but a complete frame replacement… import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ImageIcon; import javax.swing.JFrame; import … Read more

How to set Icon to a JLabel from an image from a folder?

This is my directory structure : packageexample | ——————————————- | | | build(folder) src(folder) manifest.txt | | swing(package) ComboExample.java | imagetest(subpackage) | ComboExample.class + related .class files This is the content of the ComboExample.java file : package swing.imagetest; import java.awt.*; import java.awt.event.*; import java.net.*; import javax.swing.*;      public class ComboExample { private String[] data … Read more