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 want to implement an editor where I need to have different shapes on the left-side panel and drag and drop different shapes on the right-side panel where i should be able to drag and adjust the shapes in the editor and save the drawingpad in a file in swing.
Can anyone help with that? how do I get a a dragable shapes and simultaneously add or remove after selecting a particular shape from my drawing pad.
First, you need a Shape container package (like my Area one)
Second, if you want to drag and drop shapes from a toolbar panel, you'll need a MouseInputListener to listen for toolbar clicks on the shapes, change the cursor, and handle the drop on mouseReleased
Good luck!
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 last year.
Improve this question
I am currently using JavaFX Pane and have a ball class (an Imageview) within it that I want to bounce off the edges of it like is detailed here however the minX of the Pane seems to get smaller as the ball goes off the edge of it.
It seems the Pane resizes to fit all the nodes added to it, meaning I can't ever check if the ball goes off the left side of the Pane. Is there a way to prevent this resizing or a better way to check the edges of the Pane?
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
If I have a grid of 9 panels within another panel and I want to be able to click a subpanel and on click, send the content of that panel to a 'selected panel' area, how would I go about this? (Imagine a character select page for a videogame. When a player selects their character, it shows an expanded view of the character in a 'selected' pane)
I'm thinking of mouseListeners for each subpanel and retrieving the clicked component but I don't understand how I can copy that clicked component to a 'selected' area.
Add your items to a JList or single-colum JTable. Add a ListSelectionListener to your chosen component. Specify ListSelectionModel.SINGLE_SELECTION. In your valueChanged() handler, the ListSelectionEvent will tell you what value was selected. Use that information to fill in the fields of an adjacent panel. A complete example, illustrated below, is seen here.
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 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
1
I have gone through the code on Java documentation for Swing look and feel, but I could not find much about how to modify the default look of JButtons.
I want to have rounded/curved corners for JButtons in Swing.
Is there a way to achieve this?
What functions and values should I use?
I have used the statement below:
generateButton.setBorder(new RoundedBorder(20));
The code for RoundedBorder I found in Stack Overflow question Rounded Swing JButton using Java:
I do get a black rounded border outline around the original button. MY button has orange background. But it doesn't remove the orange area outside the rounded corners. Also I do not want the black border.
How should I go about this?
You can easily use a Java Swing theme like Nimbus.
Or check out Stack Overflow question Make a button round.
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 9 years ago.
Improve this question
I try more script to set background in JInternalFrame but no one successfull. Can anybody help me?
Basically, this is the same concept as setting the background image for a JFrame
You Could
Create JLabel, set the image as the labels icon and set the label as the JInternalFrame's content pane, making sure you set the layout manager for the label (or content pane after you changed it)
You Could
Create a custom panel, that paints the image via the panels paintComponent method
This is good if you want to make the background resizable as the window is resized
Take a look at Java: maintaining aspect ratio of JPanel background image an example
You would then, simply set this as the frame's content pane