how to create own file with icon that inherit from JFrame icon, that I set it, in java and my own file use FileOutputStream and ObjectOutputStream

@David is correct that the host platform owns the JFrame decorations, but you may be able to leverage the JInternalFrame icons, which typically recapitulate those of the platform. For example, private static final Icon ICON = (Icon) UIManager.get(“InternalFrame.closeIcon”); Other decorative defaults are enumerated here. SSCCE: import java.awt.EventQueue; import java.awt.GridLayout; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JFrame; … Read more

Java Drag-n-Drop files of specific extension on JFrame

The last time I checked, this didn’t work on Mac’s, but that might have changed with Java 7… Now, remember, when it comes to drag’n’drop, there is no easy answer that will do everything. import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.dnd.DnDConstants; import java.awt.dnd.DropTarget; import … Read more

Java getting download progress

A working example, using your code and displaying the progress in a progress bar could look like this: import java.io.BufferedOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import javax.swing.JFrame; import javax.swing.JProgressBar; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; public class Progressbar { public static void main(String[] args) { final JProgressBar jProgressBar = new JProgressBar(); jProgressBar.setMaximum(100000); JFrame frame … Read more

How to focus a JFrame?

Call the requestFocus() method. This is not guaranteed to work, because there are many reasons why an operating system would not allow a frame to have focus. There could be another frame with higher priority in a different application. There are also some linux desktops which (if I recall correctly) do not allow frames to … Read more