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
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 2 years ago.
Improve this question
If I have a component inside a panel with a border layout (it could be any other layout), is there a way to get the component's placement in the panel layout?
For example, I add a label to a panel that has a border layout
panel.add (label, BorderLayout.NORTH);
In this case, what I want to get is the orientation of the Label inside the layout (which would be "North")
As can be seen from the API docs, specifically for BorderLayout there is getConstraints​. However, more generally neither LayoutManger nor LayoutManager2 has such a method.
Typically for these sorts of scenarios your code would keep track of the information in a convenient way. Likewise for events, it is much better to keep track than use the likes of EventObject.getSource.
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'm creating a java application.there I want to keep jframe in maximized state.and I want to use it many of monitors that have different screen size.and I want to components in jframe to resize with jframe.also I need to add image to the background of the frame.that image also should resize with the jframe. how to do that?
Layout managers, layout managers, layout managers
Start by taking a look at
A Visual Guide to Layout Managers
How to Use Various Layout Managers
Using Layout Managers
You might also want to have a look at Full-Screen Exclusive Mode API, depending on what you're hoping to achieve
also I need to add image to the background of the frame.that image also should resize with the jframe. how to do that?
Java: maintaining aspect ratio of JPanel background image
How to set a background picture in JPanel
How do I resize images inside an application when the application window is resized?
I see lots of searching and research in your future.
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!
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