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 5 years ago.
Improve this question
I am currently in Gr 12 and recently we received a assessment task. The task asks us to create GUI screens and then code everything behind it. Problem is that our teacher never explained to us how to code GUI screens and since exams are approaching, she won't really help us. I created the GUI screens in Netbeans using JFrame forms. From there on out, I am lost. I am using a text file to read from and I know how to code an array, display and basic class. I need help though because I don't even know where to start. If someone can help me, it would be greatly appreciated. Even if we need to talk about it more somewhere. Thank you
Create a new project in NetBeans
and then create JForm by
then select design from toolbar
now drag and drop elements from palette
click on button properties then choose ActionPerformed
this code will generates in source code write code there
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
When i start the Jframe "VentanaPrincipal" this one looks like this:
but when I open the Jframe from another Jframe, it changes the format of the components:
My code is:
VentanaPrincipal vp = new VentanaPrincipal();
vp.setVisible(true);
Can you please help me?
The Look and Feel (LAF) is changing.
Swing components use the LAF at the time the component is created.
It would seem that one frame uses a different LAF so the second frame inherits that LAF when it is created.
Fix your code to use the same LAF.
Read the section from the Swing tutorial on Modifying the Look and Feel for more information.
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
I'm trying to place some images on a JPanel and make them "relocatable" so I can click on one of the images and move to somewhere else on the JPanel while holding the button. It works fine with one image but I just can't come up with a solution for more images than one. I have checked many examples and tried many different ways. If you have any idea please share with me. Thanks!
It works fine with one image but I just can't come up with a solution for more images than one.
You can use the Component Mover. You register the component with the class and then you can move any component.
Or if you don't need the full features of the ComponentMover class you can just use the basic listener for dragging a component.
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 1 year ago.
Improve this question
I need to develop a Java programe using NetBeans. And In a JFrame I need to add a a image of planetary system and when the user sets a date and a time, Planets should rotate to their relevant positions. I don't have any idea about this yet. What is the possible way to do this? Please tell me soon
There are literally dozens of ways this might be achieved.
You could use:
Swing Timer
The Timing Framework
Trident
java-universal-tween-engine
The last three are animation engines. Personally, I use the Timing Framework, but that's more to do with what I'm familiar with and my needs at the time.
You'll probably need to do a lot of custom painting to get this to work, take a look at:
Custom Painting
2D Graphics
For more details
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 want to design the interface of a chess game, such that the chess game is within the internal frame(window) and the external frame should have a file and settings menu bar and a background image only.
The user should use new game, save game , and undo from the file(menu bar). I have written the game code but cannot figure out that type of interface. Can anybody here help me how to figure it out? I appreciate any help.
Add a JDesktopPane to the MainFrame. You can add a background to it.
Use a JInternalFrame for gameboard frame.
When use click new game from the JMenuItem, an actionPerformed should add the JInternalFrame to the JDesktopPane and make the JInternalFrame visible
If you don't understand how to create an interface at all, you should take a look at the Swing tutorials
Specifically, have a look at
How to Make Frames
How to Use Internal Frames
How to use DesktopPane
How to use Menus
How to write listeners.
If you understand the above fore-mentioned things, an you want a quick solution, look into a GUI Builder tool like Netbeans GUI Builder. If you don't understand the above concepts, I suggest you learn to hand code before working with auto-generated code, as it might overwhelm you.
One way is for the external frame/JFrame to keep a reference to the internal JFrame, and in the external frame's ActionListeners, you can then call upon the internal/game frame's public getters, setters and various methods to change the game's settings or read the current game state. Figuring out the details of how to do this is the fun part!
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 would like to implement a game board in swing (needs to be a table, though about either jtable or gridlayout etc ...) where I will be able to drag and drop a picture on to this game board and all the cells that the picture fell on will get a notification that they were chosen.
Can anyone help with that? how do I get a couple of cells in a table know that an object was dropped on them?
Have a look at this tutorial.
I think you have to spent some time with Google. I found the following with a little time with Google.
Introduction to DnD
How to drag and drop with Java 2, Part 1
How to drag and drop with Java 2, Part 2
Drag and Drop Effects
Hope this helps :)
Read this and if you have an more specific questions come back and ask them.