jframe

When a superclass extends JFrame

Hi, I am trying to use a class which extends JFrame to build a GUI. ex : class Deck extends JFrame The GUI is built in its constructor. Now when I extend Deck from another class, ex : class Pile extends Deck New windows are being created whenever an instance of the subclass (Pile) is started. Is this happening because the subclass...

Swing: Setting a function key (F2) as an accelerator

I have a menu item, "rename", for which F2 is set as an accelerator. Indeed when the menu is displayed there a little "F2" indication next to "rename". Sadly, this does not work. This accelerator triggers no response. When I change the accelerator to CTRL+F2 - it works. It seems that I should use an InpoutMpa/ActionMap. The problem wi...

Making an Unfocusable Window in Java

(SOLVED: a WindowStateListener and a deferred call to toBack whenever the window is focused) Hello all! I've been trying to figure out how to make a java.awt.Window (any subclass will do) so that it cannot be brought to the front. I'm working on a Java "Samurize-like" program that appears below all the application windows and displays ...

Java Swing: dispose() a JFrame does not clear its controls

I have a closeWindow() method which uses dispose() for the current JFrame to close down. When I show the window again, the controls (textboxes, lists, tables etc.) still have their previous values in place that were there when I dispose():d the frame... Why is that? Is there another way to completley close and clear a frame? This is the...

Fickle JMenuBar

I ran the following code 10 times. Of the 10 runs, 3 showed both the menu bar and the rectangle, 3 showed only the rectangle, and 4 showed nothing at all. What am I doing wrong? import java.awt.*; import java.awt.event.*; import javax.swing.*; import static java.awt.Color.*; import java.awt.image.*; public class GUI extends JFrame imp...

JFrame not being made at right dimensions

This code, when run, will make a window but not at the specified dimensions. What is wrong with it? import javax.swing.*; import java.awt.*; public class Windowing { void JFrame(){ JFrame frames = new JFrame("Total recall"); frames.setSize(1000,8000); frames.setVisible(true); frames.pack(); /...

BufferStrategy vs DIY Double Buffering in JFrame

Until now, I've done double buffering by creating and Image, drawing what I wanted to that Image using its associated Graphics object then draw that Image to the screen using the paint method's Graphics object. Recently, I learned about the BufferStrategy class and its uses. I was wondering what are the pros and cons of the two methods. ...

Form.java extends JFrame

I'm a starter at Java. I'd like to create a Form class that extends JFrame to use. Everything works ok, it sizes and centers well on the screen. I just can't add components to it. What am I missing. Googled every class up, couldn't find anything. Main.java: package pongLib; import pongUI.*; public class Main { public static void...

how to access jtextarea from one jframe to other jframe.

i m having 2 jframes.in 1 jframes,i am giving input in jtextarea,that should be displayed in another jframe jtextarea.how can i get that. i m using netbeans,i have designed jframes using swing. can anyone help me. ...

How can I check if something leaves the Screen? - JFrame

I have a ball based on a component and I've thought that using the isShowing() method would do the trick but after my ball leaves the container, (Pong game) the isShowing() method still returns true. So does the isShowing() method check if the component is still in the container's... bounds? Or just if it is visible and the container is...

How do I Hook a JPanel into parent/ancestor Container's windowClosing/Closed listener?

I want to create a 'generic' JPanel which can be rendered in any of the higher level Window classes (JFrame, JDialog, or JInternalFrame to be somewhat precise.) I want to be able to 'clean up' some static values when that window is no longer being rendered on screen. Normally, I would do this with a Window class (like JFrame) and simply...

Swing Component JFrame visibilty

I have a swing component: a JFrame in fact. I noticed that when my code myframe.setVisible(flag); is executed it becomes invisible if flag is equal to false and visible otherwise. Does anybody know why? ...

How do you position objects in JPanel with BorderLayout?

I have the following class which implements 3 JPanels. 1 Panel has a label, next are the buttons and the third is a table as described in my code: import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.table.*; import java.util.*; import javax.swing.event.*; class netTable implements ActionListener, Tab...

Can I create a JFrame with multiple images?

Here is my problem: I have an application that every iteration it returns to me a list of images. The imagens have different sizes and the number of images to be shown varies every time. Is there a way to show in a jFrame all the images without knowing the number of jPanels to create? Is there an easy way to do that? Obs.: The images ...

JPanel not displaying in JFrame - Java

Server is a class I made that extends JFrame. Server serverApp = new Server(TITLE, WIDTH, HEIGHT, true, false); I've effectively removed almost all the other code but the problem still remains! c = getContentPane(); c.setLayout(new BorderLayout()); //Components /***AHHHHH***/ lblEnterMessage = new JLabel("Enter ...

Problem - Container changing size automatically in Java

I've found that my container is actually changing it's size a short while after being constructed When it's constructed, I set my components to be at the place I want (like 30px away from the right edge) but later after a short while, I find that it turns from 1008x730 to 1018x740... (My JFrame is 1024x768) Does anyone know why this h...

How to put a text area (JTextArea) into a window (JFrame)?

I have a working code which creates a window with a text area. The code is here. I try to figure out how this code works. A lot of things are clear: The main-method creates an instance of the TextAreaDeom class (which is subclass of the JFrame). In other words, the main-method creates a window. In the main-method we set some "parameter...

Unable to view visualcomponent in a JPanel(SWT) with JMF

I am trying to write a small app to play videos using JMF 2.1.1e in Netbeans 6.8, I have cross-posted it at Sun Java Forums and Netbeans Users forum (link can't be added since I am a new user). The code is as follows, package demo; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.util.logging...

JFrame not working after first instantiation?

As part of a larger application, I am writing a settings class, which collects and stores user-defined settings. This class is a singleton, and is instantiated during application startup. In order to accept user input, two different GUI frames are insantiated from within ConfigSettings.java, from a public static method, selectSettings(...

Why Java jFrame setResizable() is failling to act?

This code is automatically generated by Netbean 6.8 GUI builder. The default application was not contained in a jFrame! It was in jPanel only which I didn't know how to make it none re-sizable. so I added a jFrame to contain all of them and although I set its setResizable(); to False...it still re-sizable! Here is the code: import o...