jframe

JFrame's position and pack() in Awesome WM [closed]

六眼飞鱼酱① 提交于 2019-12-25 18:28:04
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . every time when I call pack() method on JFrame, it moves to the initial position where was when started. When I try to get the location of the JFrame

Using JTextField for user input

拜拜、爱过 提交于 2019-12-25 17:04:51
问题 Thanks for your help guys...now the program works and runs like it should.. but I have 2 more question. 1.How can I get the output into a JTestField t4 or t5 2.How can I close the application using the JButton Buton3 import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.JButton; import javax.swing.JFrame; public class TriangleFarfan{ JFrame Triangle = new JFrame("Triangle Calculator"); JButton Button1 =

Minimizing a supplementary JFrame when main application JFrame gets minimized

£可爱£侵袭症+ 提交于 2019-12-25 16:57:12
问题 The application I'm working on contains a main JFrame, from which users might eventually open another supplementary frame. I am trying to implement such a behavior of the app where the supplementary frame is minimized (iconified) as soon as the main frame gets minimized. I was thinking of overriding the setExtendedState method of the main frame to capture the moment when it gets minimised, and then fire property change event from there so that the supplementary frame may act upon to it. I

Gradient background in a JFrame

浪尽此生 提交于 2019-12-25 16:53:46
问题 I have googled this and read a lot but did not find an answer that suits my needs, so I'll ask here: I would like to have a gradient background in my JFrame. Currently the background is a single colour. My code looks something like this: //imports public class Game { //some other irrelevant instance variables JFrame frame = new JFrame("Game"); public Game() { frame.getContentPane().setBackground(new Color(200,220,200)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout

Disposing a jFrame usinga button from another jFrame in netbeans [duplicate]

爷,独闯天下 提交于 2019-12-25 14:12:53
问题 This question already has an answer here : Closing a jFrame using a button from another jFrame in netbeans? Dispose JFrame from another class (1 answer) Closed 4 years ago . Is it possible to dispose a jFrame using a button of another jFrame? If it is possible, how should the codes look like in netbeans? 回答1: Is it possible to dispose a jFrame using a button of another jFrame? Yes. If it is possible, how should the codes look like in netbeans? In the JButton's ActionListener: myOtherFrame

Set icon in JFrame

社会主义新天地 提交于 2019-12-25 13:43:07
问题 I want to change the icon of the project instead of java icon. When the program icon is being displayed in status bar, it should be displaying the customized icon instead of default java icon. I am using the following code. Please suggest me what's wrong in this code. class newframe extends JFrame { Container cp; newframe() { cp=this.getContentPane(); cp.setLayout(null); } public static void main(String args[]) { newframe frm= new newframe(); frm.setbounds(0,0,1000,800); frm.setVisible(true);

Java JFrame draw

两盒软妹~` 提交于 2019-12-25 12:09:14
问题 I'm currently working with JFrame and I'm trying to draw a rectangle but I don't know how to execute the code paint(Graphics g) , how do I get the Graphics object? package com.raggaer.frame; import java.awt.Dimension; import java.awt.Graphics; import javax.swing.JFrame; public class Frame { private JFrame frame; public Frame() { this.frame = new JFrame("Java Snake"); this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.frame.setSize(new Dimension(500, 500)); // DRAW?? this.frame

Java JFrame draw

邮差的信 提交于 2019-12-25 12:08:58
问题 I'm currently working with JFrame and I'm trying to draw a rectangle but I don't know how to execute the code paint(Graphics g) , how do I get the Graphics object? package com.raggaer.frame; import java.awt.Dimension; import java.awt.Graphics; import javax.swing.JFrame; public class Frame { private JFrame frame; public Frame() { this.frame = new JFrame("Java Snake"); this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.frame.setSize(new Dimension(500, 500)); // DRAW?? this.frame

Showing JDialog on taskbar does not look good

跟風遠走 提交于 2019-12-25 11:47:39
问题 Following the posts Showing JDialog in taskbar not working and Show JDialog on taskbar I have tried to show my JDialog in the taskbar. Although it worked, the behaviour is strange and it does not look good. So a button appears in the taskbar, but when I click on it a small window appears in the top left corner of my desktop. This window is so small that its content is not visible. When I enlarge it I can see it's empty. My JDialog only appears after I close this window. Is there a way to get

Ask user if wants to quit via JOptionPane

早过忘川 提交于 2019-12-25 11:47:22
问题 I'm using this code to confirm the user whether wants to quit or not when he CLICKS THE RED CROSS CLOSE BUTTON OF JFrame (right upper corner) Object[] options = {"Quit, My Computing Fellow", "No, I want to Work more"}; int Answer = JOptionPane.showOptionDialog(null, "What would you like to do? ","Quit:Continue", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,options[1]); if(Answer == JOptionPane.YES_OPTION){ System.exit(0); } else if (Answer == JOptionPane.CANCEL