jframe

JFrame.dispose() vs System.exit()

浪子不回头ぞ 提交于 2019-11-26 20:24:25
What is the difference between these two methods - System.exit() and JFrame.dispose() ? If we want to close a Java Swing application when a button is clicked, which method should I use? System.exit(); causes the Java VM to terminate completely. JFrame.dispose(); causes the JFrame window to be destroyed and cleaned up by the operating system. According to the documentation , this can cause the Java VM to terminate if there are no other Windows available, but this should really just be seen as a side effect rather than the norm. The one you choose really depends on your situation. If you want to

How can I refresh or reload the JFrame? [closed]

大兔子大兔子 提交于 2019-11-26 20:13:34
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 months ago . I am doing project using Java and in that I need to reload whole JFrame after clicking particular button on that JFrame . How to do this? 回答1: Try SwingUtilities.updateComponentTreeUI(frame); If it still doesn't work then after completing the above step try frame.invalidate(); frame.validate();

How to hide a JFrame in system tray of taskbar

主宰稳场 提交于 2019-11-26 19:56:05
I'd created a JFrame and want to hide in taskbar (in windows not visible right in the bottom but hidden in the tray menu items ). Can anybody tell me how to do that? Did I need to make some changes in System settings of windows ? for example, you might have seen some download managers , team viewer , 4shared desktop , etc. are hide in taskbar's tray menu items. Mohammad Faisal 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

How to make a JFrame button open another JFrame class in Netbeans?

↘锁芯ラ 提交于 2019-11-26 19:45:50
问题 I have a JFrame class and it was made in the design section on Netbeans. I am trying to make a log in button that takes closes the current frame and opens another, is there anyway I can do that? I have tried: JFrame frame = new JFrame(); But I want it to be editable in the design section! 回答1: Double Click the Login Button in the NETBEANS or add the Event Listener on Click Event (ActionListener) btnLogin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {

Drawing a background image

元气小坏坏 提交于 2019-11-26 18:41:08
问题 I draw an image which is my background image, everything is fine but when I'm trying to add some JButtons to the frame the whole business goes wrong the picture that I drew disappear and I see the original background. The picture drawing looks like that: public void paint(Graphics g){ g.drawImage(bg, 0, 0, null); } I guess my problem is something with the paint method, need to be mentioned that I'm extending the JFrame class. edit: Here are some pictures to demonstrate what I mean. It first

JFrame not updating before thread.sleep()

匆匆过客 提交于 2019-11-26 18:40:14
问题 I'm creating a board game using a GUI and JFrames/JPanels where you can play against the computer. I have a method called showPieces() which updates board GUI by changing the image icons on an array of buttons (which are laid out in a grid format). Once the icons have been updated the revalidate() and repaint() methods to update the GUI. The showPieces() method has a parameter that needs to be passed to it every time it is called. The main issue I'm having is I want the human to make a move,

trouble obtaining variable info from another JFrame

北战南征 提交于 2019-11-26 18:35:29
问题 I am trying to create something similar to a JOptionPane but will obtain more than one(3) variables from input. So I figured I would use a separate JFrame that had three textFields. I used access methods like Get and Set to get the variables from one class to another, but I am getting a null pointer excpetion. I figure I am going about getting the variables the wrong way, and am having a hard time trying to find a viable solution. public class Instructor() { public void Insert(JPanel panel) {

Swing: resizing a JFrame like Frames in Linux e.g

拜拜、爱过 提交于 2019-11-26 18:29:03
问题 I would like to know if theres a possibility to implement the resizing of a JFrame in that manner, that it's been resized like for example the standart windows in linux. To be more precise: If the user starts do drag, only the future size if the window will be previewed, while the original content is not resized. As soon as the user releases the mouse, the Frame resizes to that size. In images: (1) state before resizing (2) user starts to drage (at the red circle) (3) user releases the mouse,

How to minimize a JFrame window from Java?

为君一笑 提交于 2019-11-26 18:23:18
问题 In my Java app, I have a JFrame window, how can I minimize it from my Java program ? 回答1: minimize with frame.setState(Frame.ICONIFIED) restore with frame.setState(Frame.NORMAL) 回答2: Minimize: frame.setState(Frame.ICONIFIED); Another way to minimize: frame.setExtendedState(JFrame.ICONIFIED); Normal size: frame.setState(Frame.NORMAL); Another way to normal size: frame.setExtendedState(JFrame.NORMAL); Maximize: frame.setState(Frame.MAXIMIZED_BOTH); Another way to maximize: frame

how can i change the color of titlebar in JFrame?

折月煮酒 提交于 2019-11-26 17:54:59
I am using the following code, UIManager.put("JFrame.activeTitleBackground", Color.red); for change the toolbar color in JFrame. But it didn't work. Is it possible to change the color of titlebar in JFrame? Its not possible. The top level JFrame is controlled by the look & feel of the underlying OS. You CAN change the color of an InternalFrame . //source : javax/swing/plaf/metal/MetalTitlePane.java import javax.swing.*; import javax.swing.plaf.*; import javax.swing.plaf.metal.*; public class TitleColor { public static void main_helper (String args[]) { JFrame f = new JFrame (); f