Method To Wait On Different Swing Window?

Dec 20, 2014

I am trying to create a gambling POS system and having problems with a method trying to get a value right after it was set. A jbutton sets another jframe visible which contains buttons. Upon action of the button, a value is set and the jframe is disposed.

private void btnPrizeActionPerformed(java.awt.event.ActionEvent evt) {
PrizeSelling prize = new PrizeSelling();
prize.setVisible(true);//create prize selection window
bin = getButton(); //gets what button is selected to load the correct prizes for correct game
prize.DBconnect(bin);//sends bin number to prize loading method

[Code] ....

As soon as btnPrize is clicked it gets the total value of the prizes selected which of course is 0 because it is ran before it is set. How can I make it wait until the window is closed before continuing?

View Replies


ADVERTISEMENT

Tell Java Method To Wait One Second?

Jul 4, 2014

I want to tell my java method to wait one second while something else is happening. Why not use Thread.sleep(x)? For me it stops the whole program and does not let that some else happen. Why not use wait(x)? It crashes. I tried using timers, but that doesn't solve the problem... Isn't there a simple "Java please wait 1 sec for him to catch up"?

View Replies View Related

Swing/AWT/SWT :: What Makes Java Wait On JFrame

Mar 8, 2014

With a simple "Hello World" application, once the println is executed the application exits and the process goes away.

If a simple Frame application is executed, the Frame is displayed, the println is executed but the application does not exit.

public class Frame3 extends JFrame
{
Frame3() {
setBounds(100,100,300,100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String args[]) {
new Frame3();
System.out.println("You are here");
}
}

It isn't that Java is aware an object exists because if I create a basic non-swing, non-gui object it will exit right after the println.

Q1. What is it that causes Java NOT to exit after creating the JFrame?
Q2. What type of object(s) when created will cause the application to continue running?
Q3. What would I do if I wanted the println statement to be executed only after the JFrame was closed?

View Replies View Related

Swing/AWT/SWT :: Wait For Mouse Click Before Running While Loop

Oct 7, 2013

I've got the game working just fine, but I don't like the way it starts playing the second you hit the "Run Last Class" button in Eclipse, and would really like to have the game start, then wait for the user to click a button before running the core WHILE loop. Everything is implemented in a single class, and here is the playGame method that starts the ball moving:

private void playGame(){
while (!gameover){
moveBall();
checkForCollisions();
}

All I want to do is pause before the WHILE loop until the users clicks the mouse button, nothing fancier than that! I've done quite a bit of reading, and it looks like ActionEvent may be the way to go, but I'm not clear on how to use it correctly in this scenario.

View Replies View Related

Swing/AWT/SWT :: Simplest Window Possible

Feb 5, 2014

Is it possible to display an AWT Window only(just 'cause feel like doing it)? Or, is the simplest window possible to display a JFrame?

View Replies View Related

Swing/AWT/SWT :: Displaying PNG In A Window

Jan 31, 2014

That's my third day working in Java using Swing and the IntelliJ Idea IDE.I'm trying to do something as simple as displaying a PNG in a window, and I'm doing this:

public class AboutRapide {
public JPanel mainPanel;
private void createUIComponents() {
mainPanel = new ImagePanel();

[cod]....

the problem is that, in the paintComponent method, the Image is never found when I run my app from the IDE, but it is when I run it from Finder in my Mac. Same application. I think it relates to how the application is launched so I guess what's a proper way to refer to a resource file with an image so it can be displayed no matter how the application is launched?Also if I generate a Jar for the application, as the resource gets into the Jar compressed file, it can't also be loaded.

View Replies View Related

Swing/AWT/SWT :: Creating Circular Window?

Aug 20, 2014

I want to develop an application, which shows a circular window with close, maximize buttons.

I want to create something like this: [URL]

View Replies View Related

Swing/AWT/SWT :: Dragging Window Downwards - Screen Alignment?

Oct 29, 2014

I am trying to drag the window down wards and screen has alignment issues. I tried to use WindowListeners, Component Listeners, MouseListeners ect…

But still this problem persists as only I release the mouse after drag down it appears fine that we have handled ComponentResized() method. So how to restrict component size while keep dragging down?

View Replies View Related

Swing/AWT/SWT :: Child Window Doesn't Open

Mar 23, 2014

sale s = new sale();
jDesktopPane1.add(s);
s.show();

says not a suitable method?

View Replies View Related

Swing/AWT/SWT :: JButton Opening New JFrame In New Window

Oct 14, 2014

We are creating a quiz as a school program, we are using netbeans and we have a little problem. The problem is that our JButton opens a new JFrame in a new window and we want it to stay in the same window. The code we are using is:

private void PlayButtonActionPerformed(java.awt.event.ActionEve nt evt) {
Question1 s = new Question1 ();
s.setVisible(true);
}

Is it possible to make it stay in the same window?

View Replies View Related

Swing/AWT/SWT :: Creating New Window Or Call Existing One

Oct 13, 2014

Will the code below just create a new blank window rather than call the one I have? I want to call the one I have from my main method ideally.

JMenuItem menuDelete = new JMenuItem("Delete");
menuDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DeleteEnvironmentWindow deleteEnv = new DeleteEnvironmentWindow();
deleteEnv.setVisible(true);
}

View Replies View Related

Swing/AWT/SWT :: Notification Window Minimized As The Messenger

Feb 17, 2014

I need that when my application is minimized notify you when something happens, like the messenger (MSN) remember? The window notifying a new message, the minimized window blink in orange, orange need not be ok? I do not even know where to start.

View Replies View Related

Swing/AWT/SWT :: WindowListener Not Being Called When Clicking X To Close Window

Oct 14, 2014

I have added a windowListener to my JFrame but for some reason it is not being called when I click X to close the window. I need to send a message to a server to notify it that the client window is closed. Some code snippets below (some lines excluded for brevity):

public class ChatGUI extends javax.swing.JFrame {
....
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); // I have all the window constants here but has no effect other than closing the window without calling the listener...
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosed(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
});
....
private void formWindowClosed(java.awt.event.WindowEvent evt) {

[code]....

This is resolved, needed to use...

addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});

... instead.

View Replies View Related

Swing/AWT/SWT :: Getting Icons To Change Size With Window Resize

Jan 19, 2014

I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). URL...

So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implimentation of it, and how would I fix this?

View Replies View Related

Swing/AWT/SWT :: Getting Icons To Change Size With Window Resize?

Jan 16, 2014

I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). Someone suggested to me to use this custom stretch icon class, found here:

[URL] ....

So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implementation of it, and how would I fix this?

View Replies View Related

Swing/AWT/SWT :: Jscrollpane Not Shown Until Adjust Window Size With Mouse?

Nov 16, 2014

So for a test i have a small array set as a jlist which is the contents of my jscrollpane, and it appears as if nothing is there until i adjust the window size by dragging it out or in... whats going on?

Here is the full code

import java.awt.BorderLayout;
import java.awt.ComponentOrientation;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;

[Code] ...

View Replies View Related

Swing/AWT/SWT :: Getting Jlabel Icons To Change Size With Window Resize?

Feb 20, 2014

I'm trying to create a chess program in java swing, and for the board I'm using an 8 by 8 array of jlabels stuck inside a jpanel with a grid layout. I would like the board to change size when the window changes size, and the grid layout accomplishes this succesfully, until I add the actual icons to the jlabels. Then the board just stays a fixed size. Someone suggested I use their "Stretch Icon" class, found here:[URL] ...., so I tried initializing the icons using one of the constructors in the class (the one that takes an image name and a boolean value for whether or not you want the resisizing to be proportionate (to maintain the aspect ratio)). However, the same thing happened. The board appears, but it does not resisize. To attempt to fix this problem, I tried simplifying my code, reducing the program to two jlabels within the jpanel, for which I then tried to set the image in the same way. Here is my simplified code:

import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;

[Code] ....

I'm misusing the stretch icon class, or just generally what's going wrong/how to fix it?

View Replies View Related

Swing/AWT/SWT :: How To Return Values From A JForm To The Main Window On Close

Jan 26, 2014

I am making a java swing program. I have a main window that opens a JForm window when the user clicks a menu option. Then I have a button on the JForm that closes the window on click. However, I would also somehow like to make the JForm return values to the main window (according to the states of the selector components) when it is closed. How would I go about this? Currently my jForm is a seperate class called "NewGame", and inside the menu item mouse clicked method, I have the following code:

//open new game jform window
NewGame newGameWindow = new NewGame();
newGameWindow.setVisible(true);
newGameWindow.setLocationRelativeTo(null); //center window

Is there something I can add here to get the object's values upon the window's close? Or is there a way I can add that into the button clicked method on the actual jForm?

View Replies View Related

Swing - WindowStateChanged Event Updates Window Size After It Completes

Feb 12, 2014

I have a JFrame where some elements (one, for now) have to be centered manually on the contentPane when resizing the window or changing the window state. Resizing event (componentResized) works fine but the windowStateChanged event is causing problems because it doesn't seem to "update" the contentPane's new size properly - it keeps the previous value although the window's size is obviously changed. This can be seen by simply printing the result of getSize called on contentPane.

Centering is done by programmatically changing the constraint of the component (using putConstraint, SpringLayout). The issue is that getWidth used in that method returns "wrong" values which results in an uncentered component. Maybe another listener is needed here?

Additional info: Eclipse with WindowBuilder, Linux Mint 15, Java 1.7

I know about SSCCE guidelines but I cannot make this particular example both ready to compile and short.For unknown reasons, I am unable to post the code example. I keep getting this - "Post denied. New posts are limited by number of URLs it may contain and checked if it doesn't contain forbidden words."

addWindowStateListener(new WindowStateListener()
{
// no "@Override" was generated but it is the same with it
public void windowStateChanged(WindowEvent e)
{
System.out.println("EVENT: " + contentPane.getSize() + ", "
+ getExtendedState() + ", " + e.getOldState()); // amusingly, states are actually correct - interchanging between 0 (Frame.NORMAL) and 6 (Frame.MAXIMIZED_BOTH) when I maximize and "unmaximize"
tfArrayPanelCenter();

[code]....

View Replies View Related

JavaFX 2.0 :: Manipulating Several Windows (Window Inside Window)

Apr 6, 2015

I am new to javafx I start using it instead of swing i used the scene builder for my forms the problem i faced i don't know how to have main screen with menu bar at top and depending the select from the menu it will open other windows and those window must be inside my window just like for example netbeans.

I don't need to open new window in separate i need all windows inside my main window and controlling over them minimize maximize perhaps.

View Replies View Related

Command To Wait For User Input

Apr 28, 2014

I am new to Java but not to programming, and I wonder what command there is available in Java to put a pause in the program sequence, for instance when you display "press any key to continue... "?

View Replies View Related

Two Different Buttons - Wait And Resume Function

May 5, 2014

i have two different buttons. when i clicked first, the picture is shown and then when clicked second button it shown picture and both of will be closed. but i cant see second picture because immediately second button will be closed. how can i stopped second button for a 3 seconds fpr example?

View Replies View Related

Wait For External Application To Close

Jun 16, 2014

I am writing a console application that is to make use of the system editor on *NIX. For that I have written a method which writes a string to a file, launches an editor to change that file, and then reads the file again. The problem is the call to run the editor doesn't wait for that application to have closed.

Java Code: Runtime.getRuntime().exec(editorcmd + " " + tmpfn); mh_sh_highlight_all('java'); I need the program to wait for the editor to have finished.

View Replies View Related

Swing/AWT/SWT :: Window To Submit Data Freezing When Created Inside Mouse Clicked Event

Feb 18, 2014

I'm trying to right a GUI in swing, and as part of my program, I want to open a secondary window out of the main window when a mouse clicks on the main window. Then, once I click a button on the secondary window, I want that window to close and submit data to the main window (like an info form). I have almost figured out how to do this, except for one problem. By putting a variable inside my form window called "ready," and then in my main window running a loop that constantly checks if ready is true and doesn't proceed until its true, I can create the form window, modify the values in it (currently just one value called "difficulty" that's modified by a jSlider), and then when i click the "begin" button, ready is changed to true, the form window closes, and the main window can proceed. However, when I try to put the while loop checking the ready variable inside a mouseClicked method in the main window, the form window freezes when it opens, and you can't see any of its content or modify it in any way (you can't even close it).

Here is my code:

//form window class
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class formWindow extends JFrame {
private JTextField instructions1;

[Code]...

View Replies View Related

How Wait And Notify Works In Multithread Environment

Aug 26, 2014

Flow of this program?

public class ThreadA {
public static void main(String [] args) {
ThreadB b = new ThreadB();
b.start();
synchronized(b) {

[Code] ...

View Replies View Related

Swing/AWT/SWT :: Trigger A Repaint From Another Method?

Mar 5, 2014

I have two classes. One constructs my a rectangle using Graphics2D (the class is called Rectangles). The second takes a user input for the triangle, which I am passing back to the first class. I am trying to trigger a repaint of class one from the action listener I have on a button in the second class. how to trigger this event?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved