using breadcrumb in Swing [closed] - java

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.

Related

Fix the size of content in JFrame [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 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.

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.

Two window interface in java? [closed]

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!

get value from jtextfield and set it to jtable in netbeans [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 using netbean gui. i donno the code is it same or not. but atleast i had a rough idea on how to do it.
i had a Jtable, textfield and a Jbutton
i wan to enter something into textfield and after clicking the button, the textfield will draw the data from database and set it to the Jtable. everytime i key in something to text field, i wan the data to be appear in Jtable. is this possible?
i already try using jtable model. but i don't know how to create proper jtable model.
I Suggest you explore your netbeans IDE where UI designing is a piece of cake especially inserting jTextfield, jTable etc......using simple drag and drop.
(There's option to create a swing based java file by default where javax.swing.JFrame or similar classes are extended automatically. Insertion can be done via Design Tab.)
And about getting the functions to read from jTables and jTextfields. I suggest you to check the corresponding javadocs.

Synchronization between two classes [closed]

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 have created a GUI window is being called in the main method of another class. The window has a run button. The control should return to the main method only afterthe run button has been clicked. How do i get this functionality? Should i use threads?
What you're describing is the classic behavior of a modal dialog such as a JOptionPane: program flow from the calling code pauses while the modal dialog is displayed and then returns at the calling spot when the modal dialog is no longer visible.
I suggest that you look into using a JOptionPane since this is usually the simplest way to get this behavior. Please understand that JOptionPanes can display complex GUI's since the second parameter of its showXXX(...) method is of Object type and can be a JPanel that is laden with other JPanels, components, and goodies.
For example, please look at the code from the answer to this question: How can I make a JFrame modal like a JOptionPane?
Edit
You state in comment:
can i make a JOptionPane from a JFrame? i made a JFrame with three file choosers and 3 text fields and a run button.can i make a JOptionPane from this JFrame direclty?
#Alvin: now you're learning why you should not be gearing your code towards creating JFrames -- you end up painting yourself in a corner. I suggest that you re-do that little bit of code and instead create a JPanel. Then you can put it into a JOptionPane, a JDialog, or JFrame or whatever the need dictates.

Categories