Results 1 to 4 of 4
Thread: Flashing JFrame
- 11-30-2010, 10:02 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
Flashing JFrame
Hi,
I would like to create a JFrame with two specifal features:
1. JFrame should not grab focus while maximized from minimized state.
2. When a JFrame created or became maximized from minimized state, it should flash in the Windows bar until a user will grant a focus to it. (like as in ICQ clients
).
Does anybody know how the second requirement can be implemented?
Little self-explained example:
Thanks!Java Code:import javax.swing.*; import java.awt.event.*; import java.awt.*; public class JFrameTest { private static JFrame childFrame; public static Container getParentContentPane() { JPanel panel = new JPanel(); JButton button = new JButton("Create\\Restore child frame"); button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { createOrRestoreChildFrame(); } }); panel.add(button); return panel; } private static void createOrRestoreChildFrame() { if (childFrame == null) { childFrame = new JFrame("Child Frame"); childFrame.setLocation(200, 200); childFrame.add(new JLabel("Child Frame")); childFrame.pack(); setChildFrameVisible(); } else { setChildFrameVisible(); } } private static void setChildFrameVisible() { childFrame.setFocusableWindowState(false); childFrame.setVisible(true); flashInWindowsBar(childFrame); childFrame.toFront(); childFrame.setFocusableWindowState(true); } /** * Should Make child frame flash in Windows bar. * Currently, it does not work for me. * Could anybody help me to fix this please? ) */ private static void flashInWindowsBar(JFrame childFrame) { childFrame.setState(JFrame.ICONIFIED); childFrame.toFront(); } private static void createAndShowGUI() { JFrame parentFrame = new JFrame("JFrame Demo"); parentFrame.setLocation(100, 100); parentFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); parentFrame.setContentPane(getParentContentPane()); parentFrame.pack(); parentFrame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } }Last edited by ilyvatar; 11-30-2010 at 10:17 AM.
- 11-30-2010, 06:30 PM #2
- 12-01-2010, 08:31 AM #3
- 12-01-2010, 09:52 AM #4
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
MouseListener - Flashing label
By Adomini in forum New To JavaReplies: 4Last Post: 11-29-2010, 09:31 PM -
to pass a parameter from a jframe children to its jframe mother
By anix in forum NetBeansReplies: 5Last Post: 06-14-2010, 06:10 PM -
Remove Flashing in Applet
By Unome in forum Java AppletsReplies: 5Last Post: 05-30-2009, 07:26 PM -
Flashing
By Supamagier in forum Java 2DReplies: 6Last Post: 04-29-2009, 03:43 PM -
How to make a Jframe un-focusable when another Jframe is active?
By Robert_85 in forum Advanced JavaReplies: 4Last Post: 04-22-2009, 11:02 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks