Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am quite new to Java, having the following question:
I want my Swing Applications users to put in various textfields in some frames.
That should happen like this:
When the application is started, a frame opens with some textfields and a submit button.
The submit button sends the textfields data to the main method and closes the active frame.
Then a new frame opens with some more textfields and a submit button and so on.
How can I implement this in Java?
I understood that building multiple frames is not best practice, but what is the alternative?
Thanks for your help!
How can I implement this in Java? I understood that building multiple
frames is not best practice, but what is the alternative?
IMO the best alternative in your case is to have only a window (probably a JFrame), and using a CardLayout to switch between (probably) panels when an action happens. Also read The Use of Multiple JFrames: Good or Bad Practice?
Besides official tutorials that have examples, this answer provide a commented example how to use CardLayout
Related
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 5 years ago.
Improve this question
when key relese from the red marked area add new row.
First of all use a proper image description...
To your question: You can see the answer in your picture. You just have to edit the tablemodel (right side at the bottom). There you can insert a new row or a new column and put some test data into the table.
If you want to learn swing I wouldn't recommend to start with the GUI designer. Yes it's a very useful tool and probably the best GUI designer for Java atm but the downside is that you donĀ“t learn the basics of swing with that.
I would recommend to create some JFrames first via coding them by yourself and by recreating some good examples like this one: https://examples.javacodegeeks.com/desktop-java/swing/jframe/java-jframe-example/
or this:
https://docs.oracle.com/javase/tutorial/uiswing/learn/index.html
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Does anyone have any suggestions as to how I can go about creating an Effect for a JavaFX node that can simulate glass shattering and then (potentially) breaking? if the breaking is more difficult, I can skip that part. Basically I want to layer this pane over an image and then make it look like its a picture frame that then shatters. If it can then break into pieces (after some configurable delay).. that would be great as well!
I've looked everywhere but can't seem to find info on simulating the glass shatter effect in JavaFX.
Thanks!
For a simple solution I'd go with a Path that randomly extends and change the style of the path during time.
More sophisticated code could use a Canvas and paint the shattering on it. Daniel Shiffman with his Nature of Code book may be a base for you with the creation of the shatter effect.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm pretty new to Java and I'm currently attempting to make a simple work scheduling program. I'm trying to implement a way to add employee's and their info into but I'm a little stuck.
What I wanted to do was have a button that opens up a new window that will let me input their name (string), total hours to work per week (int), and their availability (array, check boxes that will translate to an array). Is it possible to customize a JDialog to do this or is there a better way to go about doing this? I tried reading tutorials on JDialogs but none of it explains how to implement multiple inputs.
I currently have it to where I'm opening up a new JFrame but I've read from multiple sources that I shouldn't do that.
Thanks for any help.
I tried reading tutorials on JDialogs but none of it explains how to implement multiple inputs.
This is no different than adding multiple components such as JTextFields, JRadioButtons, JComboBoxes in a JFrame. For both you'd create a main JPanel to hold the GUI, and then give it components and or other JPanels each using its own layout manager. Then create your JDialog or JFrame (using the API to see which constructor to use), add your main JPanel to the top level window (actually to its contentPane) by calling add(myMainPanel), pack the top level window by calling pack(), and display it via setVisible(true).
The key issue for a dialog window is often when to query its contents. If it's a modal dialog, then that's easy -- you query the contents (the state of its fields) after the call to display the dialog, since that code flow will resume once the dialog is no longer visible. For a non-modal dialog, then you'd need to add a WindowListener to notify you when the dialog is no longer visible.
For more specific help, you need to ask a more specific question and show code.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have one task from my lecture which is Java. Lecturer ask us to draw a custom chess game which is something similar with the below picture. I was thinking from past few days but are not able to get at all.
Instruction :
Sorry, if I am asking question wrongly. I am expecting some ideas and any references for in able to do this.
we can write a code for you , but instead step to start will help you more to learn.
There can be many ways to write this one of is this.
Steps to start
Create a JFrame.
Set layout to border layout
Create a JPanel -> set panel at the center of jframe
Set panel layout to grid layout of 11 x 11
Create jable objects in for loop and add in Jpanel components.
Control background color of jlabel to form a structure shown in image.
For pawn, knight,you can use jlabel images
Build you logic to move or change jlabel to acive your requirement
Update and correction are invited
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have some splashscreens in my SWT written application.
Some of them provide feedback, some provide usercontrolls.
I need to display those splashscreens in a different order.
E.g.:
Logo splashscreen
Connecting... screen
Login-usercontrols screen
Logging in... screen
etc.
Question:
What is the usual way to manage the screens.
Is there a design pattern, which allows to effectively show a new screen / hide all previous screens?
If you want just one Window visible at a time, SWTs StackLayout might be the right choice for you. Basically, all the screens are within one window, and the StackLayout shows just one of them.