Fix the size of content in JFrame [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
when I increase and decrease the size of frame by cursor , all the contents within JFrame should increase and decrease with the JFrame. If I fix the size of other component within frame, it should increase but should not decrease from its fixed size.

You need to use some LayoutManager, only then all the components inside it will resize with the parent frame. (Also it will try to keep the ratio, depending on manager you choose) There are good examples on this link, first write simple layouts and then make more complex. If this was your question in the first place of course.

Related

Tag Input in Java Swing [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
We have multiple tag input in JS ( picture )
I wanted to know is there any default Java Swing facility to do it within JTextField or JTextArea. Is there any custom look-and-feel library or plugin to do so ?
Thanks a lot !
No, there is no such component. You should be able to make your own easy enough:
Start with a JPanel using a FlowLayout and add a JTextField to the panel
Then you can add an ActionListener to the text field. When ever Enter is pressed you create a "TagComponnent" and add the component to the start of the panel and remove the text from the text field.
This "TagComponent" may just be a simple panel that contains a label (for the text) and a button (to remove) the component from the panel.

JFrame using one component on two different panels makes it dissapear [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Basically I have two panels and one label. I want this label to show in the exact same position on both panels(I'm using the card layout). But when I use the same component it doesn't show up on either panel, but it does if it's only being used on one panel. Does anyone know why?
Thanks.
No you can't do that. A Swing component can only have 1 parent.
But you might be able to create 2 JLabel objects, and give them the same Model, so they always show/contains the same data.

Android Image Looping [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I wanted to loop three images switching like this.
http://www.transum.org/software/SW/SnailRace/DiceAnimated.gif
int i=1;
while(i<5000){
enemyj.setImageResource(R.drawable.paper);
i++;
enemyj.setImageResource(R.drawable.rock);
i++;
enemyj.setImageResource(R.drawable.sciss);
i++;
}
the duration is there but there is no image showing. the image afterwards is showing fine
What you need is AnimationDrawable take a look at official page, or check it on google
You just need to use AnimationDrawable.
This is a blocking while loop - only the last setImageResource will be visible to the user.
I suggest you check out Frame Animations: http://developer.android.com/guide/topics/resources/animation-resource.html#Frame

How do I create a Java Swing component that contains only an image and a JLabel? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to make a simple component that does nothing other than draw an arbitrary image, and then directly beneath it place a JLabel for displaying arbitrary text.
How can I achieve this? I'm brand new to Swing and I'm trying to learn as I go, but I don't currently understand how I would go about doing this. I know it's a basic question, and I appreciate any help I can get.
JLabel is your friend:
JLabel label = new JLabel("Your text here");
label.setHorizontalTextPosition(SwingConstants.CENTER);
label.setVerticalTextPosition(SwingConstants.BOTTOM);
label.setIcon(new ImageIcon(this.getClass().getResource("/path/to/image/image.jpg")));

using breadcrumb in Swing [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am working on a project where user faces 5 frames . Each frame contains the data to be filled . so when he completes the one frame and goes to next frame it has to confirm that the data is filled for that I want to use BreadCrumb(or progressbar).
so how to create a BreadCrumb(or progressbar) in java swings
I want to make similar to below image in java swings
I suggest that you
create 5 images to use as your breadcrumb images. Any basic image editing program can help you with this.
Put the 5 images in ImageIcons, and put the ImageIcons in either an array or an ArrayList<ImageIcon>.
Display the current Icon in a JLabel that is part of your GUI. You can easily set the JLabel's Icon via its setIcon(Icon icon) method.
I would strongly urge you not to use "5 frames" since that is an irksome user experience and is not what the user experiences when using a professional application.
Instead create 5 JPanels that handle each part of the process.
Swap these JPanels in and out of your GUI via a CardLayout-using JPanel, one that I assume will sit on top of the JLabel that displays your breadcrumb ImageIcons.
When you swap a JPanel view, you also swap an ImageIcon. This swapping will likely be done in the same method.
Remember that it is Java "Swing", not "swings". Good luck.

Categories