jframe

Stop a jframe requesting focus

I have a small application that updates the contents of a JFrame very quickly (many times per second) and on each update (I remove a component and then add a new one, then set visibility true again) the JFrame flashes on the Taskbar (WinXp) to request focus. It's very annoying and I'm sure it can be disabled. I just cant find out where. ...

Swing: How to position JFrame N pixels away from the center of the screen at first setVisible()?

What's the code to position a JFrame N pixels (say 300 pixels in x-direction) away from the center of the screen before one calls setVisible(true)? ...

Is it safe to dispose a JFrame from a different thread in Java?

Is it safe to call the dispose() method of a JFrame from a different thread (not the EDT)? ...

How to auto resize JFrame according to content

I have created a custom JPanel that displays images (lets call it MyPanel), I have added this to JFrame's contentPane. I want JFrame to be resized automatically to fit the MyPanel when image changes. It looks like I need to call frame.pack() to do this. Calling pack() from MyPanel increases coupling so I don't want to do that. To solv...

Java: Difference between the setPreferredSize() and setSize() methods in components

Ok, I read the Java Documentation and I just can't figure out what is the main difference between those two methods. Sometimes I used setSize(), sometimes setPreferredSize(), sometimes one does what I want, sometimes the other. So, what is the main difference between the two? Which one should I use for JFrames and JPanels? Thanks ...

why isn't my Jlabels or Jpanels showing??

i've added a title to my Jframe, and now its blocked everything else, what have I done?? public class addressbook { public JFrame frame; public JButton btnadd, btndelete, btnsave, btnprev, btnnext; public JPanel panel, pTitle; public JTextField txtname, txtaddress, txthomeno, txtmobno; public JLabel JlbName , JlbHtn, JlbMtn, JlbAddress,...

Java ArrayList Help!

I am working on learning java a little, and i found this question in a java text book on Google books, I have been working on it for a while, and for some reason these seems like it should be simple. Anyone bored and would like to show me what this is suppose to look like in Java code?? (Using ArrayList) Write a program that creates an ...

How to adjust JFrame border thickness in Java

I'm using Vista, my old Java app ran on Win XP has thin borders, about 2 pixels thick, but now on Vista, the borders deafults to thick lines, maybe 6,7 pixels thick, can I specify in Java how thick my JFrame borders should be ? ...

What is this thread/paint exception about?

I'm playing with things I don't really understand at the moment for a JAVA project on a Robot exploring an unknown territory (a grid of valid positions and blocked positions). Anyway, I tried to improve the basic GUI we were given as an example of how to proceed, it had been done with a text field and various unicode characters to repres...

Dragging A Circle on a JFrame

I am trying to have a circle appear on the screen, then when the user clicks INSIDE the circle, enable the ability for them to drag the circle where the mouse goes while it is being pressed. This is the code i have so far, the drag works, but it is allowing the user to drag without them pressing the inside of the circle, just when anywh...

Press [X] button to close JFrame won't invoke dispose method

I have set up a JFrame like this: public class XFrame extends JFrame { public XFrame() { setSize(100, 100); } @Override public void dispose() { super.dispose(); System.out.println("Dispose get called"); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { ...

JMenuBar disappears when I add paint method

Im trying to use the following code to eventually make a game. The code, as shown below, works. import java.awt.event.*; import javax.swing.*; public class GUI extends JFrame implements ActionListener { public static void main(String[] args) { GUI g = new GUI(); } public GUI() { try { UIManager.setLookAndFeel(UIManag...

IntelliJ debugger makes new JFrame() break Windows Vista Java

My app works fine with Java 1.6 when I run it command line. However, when I run it under the debugger in IntelliJ IDEA community edition 9, when it gets to the line new JFrame(); the Vista reports the JVM fails with the message: Java(TM) Platform SE binary has stopped working A problem caused the program to stop working correctly....

MDI : How to create snappable internal jframes

I am interested in creating a work place consisting of multiple jframes. I would like to implement the functionality that google dashboard uses to dock their frames into a position. I would also like to be able to snap two frames together. Does anyone have any idea how google does this, how it might be done or perhaps code of an open sou...

Displaying GUI components in Java

Hi guys I have a GUI window that I've created using Netbeans. I then ported the code into my own program so that I can display .png's at my will. However, the GUI components are not displaying, and the window opens up with no size by default. I need the window to initially open up with the GUI components visible, with the window of ...

Questions regarding Extending JFrame in a class?

Okay, I'm NOT a Java noob, it just so happens that I've forgotten a tad bit about core Java while I was learning more fun stuff like MySQL, Servlets, Java EE, JDBC etc etc; so don't frame your answers as if I were a beginner. Now the question..... I'm writing a class (lets say ThisIsAJFrameExtendingClass) which extends JFrame, and to mi...

how would you detect if the mouse cursor is inside a JFrame in java?

How would you write a method to detect if the mouse cursor is inside a JFrame in java? The method should return true if it is inside or else false. Thanks, Andrew ...

How could I implement new JFrame functionality.

I am trying to remove the drag bar across the top of the JFrame. I would like to keep the minimize maximize and close options that appear on this bar available. What I was thinking was to remove the bar (and icons). Then add the icons as embedded images, that implement the JFrame actionlistener. It would also be necessary for this to wor...

java swing, i want to close one JFrame without closing another, how can i get it ?

i have three JFrames, i want to close one of them without influence to another. what can i do to get it ? thanks Peter. I want to open two(or more) JFrames at the same time, and When I close one of them(use the default close button), others is still open. ...

how do i clear my frame screen in java?

I am making a brick game. I want the screen to get clear after every 0.1 second so that i can redraw every thing on the frame screen. Is there any way to directly clear the frame screen without any event occurence?? ...