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.
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 1 year ago.
Improve this question
enter image description here
Is it possible to put a button in the table like the attached image?
NatTable is a custom painted table control. Putting real buttons in the table is possible, but actually does not really make sense and could even lead to resource issues in larger tables.
You can actually render anything if you have a corresponding painter. And for a button you of course also need the action binding. NatTable has the ButtonCellPainter to render a cell as a button. But actually the implementation to mimik the button press is a bit outdated IMHO. The corresponding example should give you an idea what you can do and how to do it.
https://git.eclipse.org/c/nattable/org.eclipse.nebula.widgets.nattable.git/tree/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_102_Configuration/Rendering_cells_as_a_link_and_button.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 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.
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'm working on a school project. I am writing Sudoku. A Sudoku block consist of 9x9 blocks. Of those 9x9 blocks the Sudoku is divided into 3x3 blocks (9 of them).
How do I color those 3x3 blocks the same color to be able to see in what block your working in (i.e. background colors)?
The cells in a JTable can be styled using a custom TableCellRenderer, which provides a flyweight component ( for example a JLabel) to render each cell. When the cell is editable, you also specify a custom TableCellEditor, which may or may not follow the same style as the renderer.
The UI state (such as the current cell you're working on, to color the group of cells) is best kept in a presentation model (can be a simple bean), which is accessible from your cell renderer and editor, to decide how to style the cell.
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.
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 would like to implement a game board in swing (needs to be a table, though about either jtable or gridlayout etc ...) where I will be able to drag and drop a picture on to this game board and all the cells that the picture fell on will get a notification that they were chosen.
Can anyone help with that? how do I get a couple of cells in a table know that an object was dropped on them?
Have a look at this tutorial.
I think you have to spent some time with Google. I found the following with a little time with Google.
Introduction to DnD
How to drag and drop with Java 2, Part 1
How to drag and drop with Java 2, Part 2
Drag and Drop Effects
Hope this helps :)
Read this and if you have an more specific questions come back and ask them.