jframe

dispose() is not the same as setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

非 Y 不嫁゛ 提交于 2020-01-05 03:32:21
问题 I noticed that if setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) is set, closing the frame will end its Process in Task Manager, but if i implement WindowListener and manually dispose() the frame, Process will remain... probably because in new Runnable() i have something like this: new Runnable() { void run() { Jsch tunnel=new Jsch(); JFrame frame=new JFrame(); frame.addWindowListener(new WindowListener() { frame.dispose(); } ); // imagine that this is legal frame.setVisible(true); } } Anyone

JFrame attached on the side of another JFrame

僤鯓⒐⒋嵵緔 提交于 2020-01-04 15:15:49
问题 I'm trying to attach a JFrame to another JFrame, it works by setting the coordinates of the 2nd jframe to the right edge of the first. But it doesn't feel like one whole because when I drag the first JFrame the second one lags behind it like a dog. Is there any way to keep them from seperating when you drag it, so it looks more like one whole? 回答1: Because the host's heavyweight peer component owns the frame, this will be difficult to do in a cross-platorm manner. On Mac OS X, you might look

JFrame attached on the side of another JFrame

醉酒当歌 提交于 2020-01-04 15:15:11
问题 I'm trying to attach a JFrame to another JFrame, it works by setting the coordinates of the 2nd jframe to the right edge of the first. But it doesn't feel like one whole because when I drag the first JFrame the second one lags behind it like a dog. Is there any way to keep them from seperating when you drag it, so it looks more like one whole? 回答1: Because the host's heavyweight peer component owns the frame, this will be difficult to do in a cross-platorm manner. On Mac OS X, you might look

Unable Take screenshot of JFrame Java Swing

℡╲_俬逩灬. 提交于 2020-01-04 11:10:23
问题 I have tried to save the JFrame as an image using the following approach. try { BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); this.paint(image.getGraphics()); ImageIO.write(image,"png", new File("Test.png")); } catch(Exception exception) { //code System.out.print("Exception unable to write image"); } I am trying to save a screenshot as follows: I would like to have even the title in my screenshot import java.awt.BorderLayout; import java.awt

Unable Take screenshot of JFrame Java Swing

喜夏-厌秋 提交于 2020-01-04 11:10:13
问题 I have tried to save the JFrame as an image using the following approach. try { BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); this.paint(image.getGraphics()); ImageIO.write(image,"png", new File("Test.png")); } catch(Exception exception) { //code System.out.print("Exception unable to write image"); } I am trying to save a screenshot as follows: I would like to have even the title in my screenshot import java.awt.BorderLayout; import java.awt

Calling function on windows close

我只是一个虾纸丫 提交于 2020-01-04 07:19:14
问题 Using Java: I have a GUI built using the netbeans GUI builder. The GUI class was created by extending a jFrame public class ArduinoGUI extends javax.swing.JFrame and the GUI displayed using: java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ArduinoGUI().setVisible(true); } } Therefore I don't have an actual frame object on which to call frame. , so how in this case can I override the windowClosed function, because I have to call a specific function to tidy up a serial

Calling function on windows close

人盡茶涼 提交于 2020-01-04 07:19:08
问题 Using Java: I have a GUI built using the netbeans GUI builder. The GUI class was created by extending a jFrame public class ArduinoGUI extends javax.swing.JFrame and the GUI displayed using: java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ArduinoGUI().setVisible(true); } } Therefore I don't have an actual frame object on which to call frame. , so how in this case can I override the windowClosed function, because I have to call a specific function to tidy up a serial

Showing Japanese Characters in TItle Bar of Java Program

有些话、适合烂在心里 提交于 2020-01-04 03:11:11
问题 I am able to display Japanese characters everywhere except for the title bar of the main window (JFrame) in Java. Is there a way to change the font of this title bar so it can display japanese characters? Thanks I am using Windows XP. If this matters I am using the Java Substance look and feel too. 回答1: A window's title bar is managed by the system window manager, not by Swing. You don't say what OS/GUI you're using. For Windows XP, open the Display control panel, select the "Appearance" tab,

How to create an array of JLabels in Java to be printed to a JFrame

房东的猫 提交于 2020-01-03 16:36:11
问题 I m trying to make an array of labels. Each label has a differented value which come out of a function. I don't know the exact number of labels to be used. I mean there could be any number of values to be printed. Please help me do this. 回答1: easy just have one method return an array or some collection of JLabels and add all of them to your JComponent (e.g. a JPanel) class MyPanel extends JPanel{ public MyPanel(){ super(); showGUI(); } private JLabel[] createLabels(){ JLabel[] labels=new

Thread.Sleep alternative in Java

蓝咒 提交于 2020-01-03 10:57:54
问题 I've been told that using Thread.Sleep() is a bad solution at times that one would want to make some time interval within a loop of actions in a synchronized method. On the other hand, I have two different threads which are active throughout the running time of my program and also one shared object and when I use Object.wait(long) in that shared object, it causes my GUI to freeze for some time. what would be a better solution for this problem? Update This portion of the code is including one