Minimizing all open windows in C#

PInvoke.net is your friend 🙂 using System; using System.Runtime.InteropServices; namespace ConsoleApplication1 { class Program { [DllImport(“user32.dll”, EntryPoint = “FindWindow”, SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport(“user32.dll”, EntryPoint = “SendMessage”, SetLastError = true)] static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam); const int WM_COMMAND = 0x111; const int MIN_ALL … Read more

How to hide a JFrame in system tray of taskbar

import java.awt.*; import java.awt.event.*; import javax.swing.JFrame; import javax.swing.UIManager; /** * * @author Mohammad Faisal * ermohammadfaisal.blogspot.com * facebook.com/m.faisal6621 * */ public class HideToSystemTray extends JFrame{ TrayIcon trayIcon; SystemTray tray; HideToSystemTray(){ super(“SystemTray test”); System.out.println(“creating instance”); try{ System.out.println(“setting look and feel”); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ System.out.println(“Unable to set LookAndFeel”); } if(SystemTray.isSupported()){ System.out.println(“system tray supported”); tray=SystemTray.getSystemTray(); Image image=Toolkit.getDefaultToolkit().getImage(“/media/faisal/DukeImg/Duke256.png”); ActionListener … Read more

Painted content invisible while resizing in Java

For reference, here is the same program using Swing. Because JPanel is double buffered, it doesn’t flicker as the mouse is released after resizing. import java.awt.*; import java.awt.event.*; import java.util.Random; import javax.swing.*; public class SwingPaint { public static void main(String[] args) { JFrame frame = new JFrame(); frame.add(new CirclePanel()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } private static … Read more

tech