Unable to achieve particular layout of components [closed] - java

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 been trying to work out how could i achieve such a layout of labels, but was unsuccessful in all of my tries.
Could you give me an idea on how to achieve such a layout of labels in java?

You can nest panels with different layout managers to achieve your desired results. This can simplify the layout in many cases.
However, in this case you might be able to use a GridBagLayout. The GridBagLayout allows you to specify the row/column of each component. Start with a two column grid.
The first and second labels will take two columns on two separate rows.
Then the next four labels will each take up one column on two separate rows.
Read the section from the Swing tutorial on How to Use GridBagLayout for more information.

Related

Is there a function to find a component layout position? [closed]

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.

how to add new row to jtable in jframe in netbeans8.0.2? [closed]

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 5 years ago.
Improve this question
when key relese from the red marked area add new row.
First of all use a proper image description...
To your question: You can see the answer in your picture. You just have to edit the tablemodel (right side at the bottom). There you can insert a new row or a new column and put some test data into the table.
If you want to learn swing I wouldn't recommend to start with the GUI designer. Yes it's a very useful tool and probably the best GUI designer for Java atm but the downside is that you don´t learn the basics of swing with that.
I would recommend to create some JFrames first via coding them by yourself and by recreating some good examples like this one: https://examples.javacodegeeks.com/desktop-java/swing/jframe/java-jframe-example/
or this:
https://docs.oracle.com/javase/tutorial/uiswing/learn/index.html

Understanding Java Course Assignment [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 6 years ago.
Improve this question
Assignment Instructions
I'm not sure what this means or what it is asking me to do, I've been programming with Java for only a few months and this seems really difficult with my limited knowledge.
From what I can tell, your assignment is to draw graphics on a panel using the required methods. The graphics can be of any color or size. Once you have done that, you are to make 3 copies of that panel which will leave you with 4 of the same panel. Then you are to put those 4 panels onto another panel and make a copy of that panel 3 times. This in reality should leave you with 16 of the original panels placed into a 4x4 grid or 4 big panels placed in a 2x2 grid. I would still recommend asking your instructor for help though, incase I am incorrect.

how to build a table of items and it's radioButtons with a dynamic size? [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 7 years ago.
Improve this question
I want to build a table, with some items, and for each item I want to have its own radioButton. but the input is dynamic. so the size of the table is dynamic, and the "ActionCommand" for each radioButton is dynamic.
what is the best way to do this?
the only way I know is to normally just make a dynamic list of radioButtons and initialize it dynamicly with the names of the items.
thank you
Depends of what you want to do after ? You have to give more details...
If it's for printing, you can take a look about JTable (or more powerful JXTable) which can handle your data with a specific model (model which you have to define).
Just remember to set the action command to each radio button before adding to the table. You'll have to take the time to read doc about this, but with some tests it givesa very good result !
Else, yeah, just a map, with the name of the item, and the radio button.

There have any idea for this [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 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

Categories

Resources