This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Issue regarding dynamically loading Images in loop using Java Swing
Can any one tell how I would add images dynamically using for loop in JToolBar. I tried a lot but it didn't work for dynamic loading of images. I want to create ToolBar where I load images in a loop.
JToolBar is particularly well adapted to adding JButton instances each having a distinct Icon, so I would advocate using ImageIcon. Complete examples maybe found here, and more were cited in comments to an answer to your previous question.
Related
This question already has answers here:
Disable JButton focus border
(5 answers)
Closed 4 years ago.
i'm new there. My first issue:
When i start my GUI java swing application in Window Builder, first object is always selected
and when i click anything (button or anything) it's show like it's clicked and i don't want it to show. What command for this?
You should use this:
button.setFocusPainted(false);
java, swing, awt, remove focus from all objects
This question already has an answer here:
Positioning component inside card layout
(1 answer)
Closed 5 years ago.
I have read this SO Question regarding this problem, but I am still a little lost on how to freely move and position swing components. I am new to Swing, and so I am still learning the ins and outs of it. I have read other documentation and articles online, but I have yet to see anything that shows how to move components around. I have even tried things set as setBounds, but it has been to no avail.
What are some ways I can position components in the CardLayout? Any help is appreciated.
Your question doesn't make sense, in that it's asking something akin to, can I move an elevator sideways. No, you can't. A CardLayout is for swapping components, and that's all it can do. The JPanel that holds it is given a preferredSize by the layout determined by the maximal preferred sizes of the contained components. This layout is not for positioning, translating, or scaling components, and for these functionalities you'd need to use other layout managers. Fortunately you can nest panels, each using its own layout manager and thereby move or translate components as your use of layouts see fit.
For more detailed answer, consider creating and posting your minimal example program.
And in fact, the question that you linked to answers this much more comprehensively, and so I've made this answer a community wiki and have closed your question as a duplicate. I strongly urge you to read or re-read the Layout Manager Tutorial.
This question already has answers here:
Exporting JUNG graphs to hi-res images (preferably vector based)
(4 answers)
Closed 9 years ago.
I have an editable VisualizationViewer inside a GraphZoomScrollPane. After moving and reorganizing the graph I want to save the edited version into a image file.
When I tried using VisualizationImageServer it requires the layout which removes the modifications and set up the nodes to the original layout.
By printing the JPanel into the image, I only get the visible portion and I need the full image to be saved.
I'm not an expert on Jung, but this question seems to provide a workable approach to what you want to do:
Exporting JUNG graphs to hi-res images (preferably vector based)
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to set background image in Java?
I am trying to put a background image on my java gui, and I can't figure out how to do it. I've looked around and tried some code but I can't get it to work. I have the imageicon setup but I don't understand where I'm suppose to put this at. Please help!
Read the section from the Swing tutorial on How to Use Icons for an example of displaying an icon.
Then, depending on your requirement, Background Panel explains how you can then use the JLabel with the icon as a background image.
Could this solve your problem? It's an explanation code which shows how you can put a background-image to a panel :) http://www.java2s.com/Code/Java/Swing-JFC/Panelwithbackgroundimage.htm
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
marquee text in android
in my app i want to have a news banner with the words moving to one side like tv .. i don't really know how to run that kind of animation .. and should the banner be a TextView ? i'm not really sure of anything .. so i just need the xml format of such thing, Thankss!
This is commonly referred to as a ticker or marquee. Here's a tutorial on how to make one.
Edit: Here's another tutorial.
Edit: Here's another stackoverflow question about the same thing.
Edit: And another.