jframe

Creating a JFrame from another JFrames constructor

I have 3 objects that extend JFrame let's call them FrameA FrameB FrameC. FrameA is my main application window. From FrameA's constructor if the application is not registered i create FrameB and FrameC. They are just popup's that indicate trial period. 2 times out of 10 application freezes and never shows the B anc C frame and frame A ...

Trying to bring swing frame to front before taking a screenshot but getting artifacts

I have a part of my app that takes a screenshot of a certain window but before I do so I want to bring the window to the front. This works fine on my Mac machine but when I tested it on in Windows XP on paralells the screenshot always has a greyed out area where the overlapping window was. It seems the screenshot is always taken while ...

Drawing over a JPanel and adding the JPanel to JFrame

I need to draw a graph over a JPanel by overriding the JPanel's paintComponent() method. While designing gui using netbeans when i drag/drop a JPanel over JFrame it generates code by creating a private variable, JPanel object. In such a case how can i override its method to draw over it... or else if i write code for a class by exten...

Closing JFrame of java applet using buttons on the system frame causes delay

I have written a java applet which opens a JFrame (so when run in the browser, it will popup a small new window). The problem is, when pressing one of the buttons of the window frame, there is a slight delay (cannot move the mouse for 2 or 3 sec) before the window will close/minimize/maximize. The hidden menu actions (accessed when pres...

action listening for a JFrame

I am trying to listen tab-in tab-out action for my swing gui that is made by JFrame. I have a JTextField added to the JFrame that will be getting the user clipboard whenever the window is selected so the user may tab between programs, copy some url so when back to my program, this JTextField will be populated by the copied url string. E...

MouseListener on JFrame

I want to be notified of mouse events (specifically the mouse entered and exited events) on my JFrame. But when i add a mouselistener to it i get the events on the borders of the frame not the entire frame with it's contents. Any ideas as to why? EDIT : Or at least do you have an alternative? I want a "gloabal" way to catch mouse even...

Calling JFrame.setGlassPane(Component) more than once

Is there any trick to calling JFrame.setGlassPane(Component) more than once? In the code below, I first call it to create a red box in the glass pane. That works fine. Then, in a mouse click handler, I call it again to create a blue box in a new glass pane. This doesn't work. The original red glass pane disappears, but the blue glas...

multiple JFrames from JAR

I have a Java application that launches multiple windows (JFrames). It works fine when I'm running it from the command line. But after packaging the app in a JAR and running it from the JAR, not all of the windows open. Does anyone know why this could be happening? Is there something about JAR files that prevent opening multiple windows...

JFrame does not hide when setVisible(false)

import javax.swing.*; class Frame extends JFrame{ Frame() { JFrame j = new JFrame(); j.setBounds(100, 200, 120, 120); j.setTitle("null"); j.setVisible(true); j.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } } public class test001 { public static void main (String Args[]){...

Forcing a JFrame to refresh

I have a UI built inside a JFrame. One of the buttons starts a long running call (still within the same java process), and during it's execution, the UI is frozen. I figured, to make it clear that things are still running, I can display a progress bar, perhaps in a popup, so that the user can be kept up-to-date as to what the program ...

Minimizable JFrame that stays on top of main application window.

My apps pops up a dialog. Users usually want to switch back and forth between this dialog and the application window for a period of time. I want this dialog to stay on top, so that it doesn't get hidden behind the main application window. But at the same time I want the dialog to have a minimize button so that it can get out of the way ...

How to make a JFrame Modal in Swing java.

Hello, I have created one GUI in which I have used a JFrame. How should I make it Modal? ...

Obtaining a JFrame from a JApplet

Given a JApplet, how do I obtain the JFrame object corresponding to this applet? JApplet applet = this; JRootPane rootPane = getRootPane(); Container contentPane = getContentPane(); JFrame jframe = ...; // How do I obtain the JFrame? ...

Placing drawing on JPanel

My program have 3 classes. 1) main, 2) frame, 3) drawingBoard. The logic of my program is that, a new drawing will be displayed every times user click on New pattern button (and this working fine). 1st class - main method public class mainPage { public static void main(String[]args){ JFrame appFrame = new Frame(); appFra...

How to make a JFrame have no taskbar button ?

I would like to have a normal JFrame with its full functionalities (decoration, title, icon, resizing, minimizing, maximizing, etc.), with the only thing that it wouldn't appear in the system's taskbar. (Typically, there would be another program opening and managing them). Is it possible ? And if yes, what is the best way to do that ? ...

What is the difference between the ways a Swing window can be initialized?

I am curious as to the differences between the following approaches to creating a Swing window: Using java.awt.EventQueue.invokeLater() in main(); Using SwingUtilities.invokeLater() in main(); not bothering with threads at all, simply instantiating the JFrame subclass and calling setVisible(true) from main without wrapping it inside a ...

Wrong packing of JFrame using JPanel in borderlayout

Hello there. I am writing a simple application in Java that does some particle simulation on a bunch of sheep (don't ask). For this I want a window with a JPanel for graphics (which will be resizable with a simple combobox that contains some standard resolutions) and some other elements like buttons to start and pause the simulation etc....

JFrame disappear behind applet's browser window

My app is a JApplet which opens a JFrame. the applet has a listener and a button, so that if the frame goes behind another window (looses focus), the user can simply click the button to get it to come to the front. frame.toFront(); This works fine. But initially (in the applet's public void init() {}), after calling frame.setVisible(tr...

Keep JFrame on top of others.

I am in a situation where i create FrameB from my main frame FrameA. When the user is working on FrameB i would like it to be on top of FrameA even when user accidentally clicks on FrameA? ...

JPanels, JFrames, and Windows, Oh my!

Simply stated, I am trying to make a game I am working on full-screen. I have the following code I am trying to use: GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); if(!gs.isFullScreenSupported()) { System.out.println("full-screen not supported"); } Frame...