jframe

How do I embed a JFrame into a JavaFX 2.0 application?

余生长醉 提交于 2019-12-04 03:42:18
问题 I have searched stackoverflow extensively for help on this topic, but the Q&As I found are old and the answers have changed for the current version of the JDK (I'm currently using 7u51). Note that I was never SUPER proficient in Swing to begin with, but I believe I understand the fundamentals. (I've always been more focused on the meat inside an app, not the GUI). I'm trying to work with a third party library. The third party library requires that it's components use JFrame. Therefore, I'm

Disable JFrame when a new JFrame is opened

烈酒焚心 提交于 2019-12-04 03:39:48
问题 I am trying to disable the "main" JFrame when the new frame pops up. I want it so you can not click or drag anything on that frame. I tried making the new frame a JDialog , but that did not disable the other frame. I also looked at the other post about this, which suggested to make it a JDialog but it still does not work. I really need help doing this please. thanks. This is the codeIi am using to make the JDialog , is their any problems with it? editDialog=new JDialog(IntroScreen.frame);

How to update JFrame Label within a Thread? - Java

℡╲_俬逩灬. 提交于 2019-12-04 03:28:58
问题 I have tried a lot, but can't seem to get it to work. I was told to use EDT with the following example. SwingUtilities.invokeLater(new Runnable() { public void run() { // Modify the GUI here } }); I have read on this topic a lot and still don't understand. I get what a thread is, but the .invokeLater still makes no sense to me. Honestly if you can explain in detail this it would be a big help! Goal of Program: To get the randomly generated key that is constantly created every second to update

Does getContentPane().add() mean the same as add()

亡梦爱人 提交于 2019-12-04 03:02:55
Does getContentPane().add() mean the same as add() ? public class TestFrame extends JFrame{ public TestFrame() { JLabel label = new JLabel("jo"); getContentPane().add(label); add(label); } } Does getContentPane().add() mean the same as add() ? Yes, since 1.5+. Mostly. To make things "easier", addImpl was changed to forward to the content pane, but in uncommon corner cases it doesn't (for instance, the content pane needs to be added somehow). This method is overridden to conditionally forward calls to the contentPane. Yes, because if you notice they both are from Class Container java.lang

how to make a frame display 50 times for 1 second and disappear each time it's displayed

醉酒当歌 提交于 2019-12-04 02:25:51
问题 I need my JFrame to display itself within the dimensions of my screen and it should display the frame with the message then disappear for 1 second then reappear 50 times here's my code so far: import javax.swing.*; import java.awt.*; import java.util.*; public class OurMain { public static void main(String[] args) { Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); int w = sSize.width; int h = sSize.height; Random rand = new Random(); int z = rand.nextInt(sSize.width); int c =

Java - Screen turns black, when setting a JFrame to Fullscreen

爷,独闯天下 提交于 2019-12-04 02:18:00
问题 I'm trying to draw something on a Canvas, add it to a JFrame and then set this JFrame to Fullscreen. My problem is: in fullscreenmode I only see a black screen. Before the screen turns black I shortly can see the pink background of the canvas. Drawing directly on a JFrame and then setting it to fullscreen works perfectly fine and I can see the testtext. I assume there is a problem with displaying the Canvas properly. Here is my code: public class FullscreenTest extends Canvas { private JFrame

Java how to make JFrames maximised but not resizable

让人想犯罪 __ 提交于 2019-12-04 01:26:33
问题 Originally (See my previous question "Java how to make JFrames start off as a maximised window") I wanted to make a window which starts out maximised. This code accomplishes this: public static void main(String[] args) { JFrame frame = new JFrame(); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setVisible(true); } However, if this window is restored down it becomes a practically non-existent bar. To solve this I set a size for the window using setSize(). This works but presents another

Stop Eclipse/Java running multiple instances

故事扮演 提交于 2019-12-03 22:14:18
I'm not a java expert or a eclipse expert. Currently I'm working on a project and i need to debug/test often. I use the eclipse run Button for it. But when I don't close the Program eclipse/java opens it again(second window). It's an gui app with swing jframe. Is there a function in eclipse or java to terminate the previous build and opens the new one when you run it? Vishal Dhawani Try the following ways: If you are in debug perspective, you can Right click running instance and click "Terminate and Relaunch" (You can bind short-cut for this from Window -> Preferences -> General -> Keys) This

WindowListener does not work as expected

为君一笑 提交于 2019-12-03 18:11:30
问题 I want my GUI to make some checks when a JOptionPane appears. Because I can't find any other way, I though I can do those each time the application window loses focus(its just checking a string). For that reason I added the following code on my JFrame: appFrame.addWindowListener(new WindowAdapter() { @Override public void windowLostFocus(WindowEvent e) { System.out.println("Focus Lost"); } @Override public void windowClosing(WindowEvent e) { //some other stuff here that work } }); The window

Adding JPanel to JFrame

試著忘記壹切 提交于 2019-12-03 17:45:51
问题 I have a program in which a JPanel is added to a JFrame: public class Test{ Test2 test = new Test2(); JFrame frame = new JFrame(); Test(){ ... frame.setLayout(new BorderLayout()); frame.add(test, BorderLayout.CENTER); ... } //main ... } public class Test2{ JPanel test2 = new JPanel(); Test2(){ ... } } I get an error asking me to change type of 'panel' to 'component'. I do I fix this error? It wants me to do: Component panel = new Component(); 回答1: public class Test{ Test2 test = new Test2();