layout-manager

JPanel & components change position automatically

[亡魂溺海] 提交于 2019-11-26 11:25:24
Hi I am working on swing application but I am facing one problem. When I first run application JPanel is positioned at proper position where I decided to set with components inside. But problem occur when I minimize & again maximize frame window jpanel automatically changes it's position. Below images shows that difference As we can see on second image components changes it's position automatically. For this I written below code, jpanel_addPurchase = new JPanel(); jpanel_addPurchase.setLayout(null); jpanel_addPurchase.setBounds(400, 0, 500, 500); jpanel_addPurchase.setBackground(Color.white);

How returns XxxSize from JComponent(s) added to the JLabel

放肆的年华 提交于 2019-11-26 10:56:57
how can I correctly returns XxxSize from JComponent(s) added to the JLabel 1st. figure >> lets LayoutManager works like as for JPanel, JLabel returns Size(0, 0) 2nd. figure >> added some PreferredSize to the JLabel 3rd. figure >> calculated PreferredSize from JComponent(s) added to the JLabel 4th. figure >> lets LayoutManager works changed JLabel to JPanel, now LayoutManager correctly calculated Dimension without using any XxxSize notice sice there is used Nimbus L&F, same output is there for all accesible L&F import java.awt.*; import java.awt.event.*; import java.util.LinkedList; import java

FlowLayout on top of GridLayout not working

岁酱吖の 提交于 2019-11-26 10:02:23
问题 I\'m trying to create a hangman game and so far it\'s coming along GREAT, but the layout design just doesn\'t seem to fall into place! The alphabet is supposed to end up in a FlowLayout order on top of the Hangman picture with the buttons \"Restart\", \"Help\" \"Add New Word\" and \"Exit\" at the bottom! What am I doing wrong? import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; public class Hangman extends JFrame { int i = 0; static JPanel panel; static JPanel

LinearLayoutManager setReverseLayout() == true but items stack from bottom

杀马特。学长 韩版系。学妹 提交于 2019-11-26 09:01:31
问题 This seems like it would be an easy solution, but it seems that setting private RecyclerView mRecyclerView; private RecyclerView.Adapter mAdapter; private LinearLayoutManager mLayoutManager; .... // More code mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view); // Add item decoration mRecyclerView.addItemDecoration(new SpacesItemDecoration(DIVIDER_SPACE)); // use this setting to improve performance if you know that changes // in content do not change the layout size of

JPanel positions and sizes changes according to screensize

女生的网名这么多〃 提交于 2019-11-26 04:27:58
问题 The program runs with its size according to screen resolution or size of the computer. When I run it in a computer with specific size of its monitor it will change accordingly. My problem is the positioning and size of a JPanel, or any object inside the frame, to adopt on the change of screen size. So whenever I will present my program on any monitor with different sizes the components will still be organized and placed as what I\'ve originally designed it. But here I\'m testing it with one

Why does the first panel added to a frame disappear?

自闭症网瘾萝莉.ら 提交于 2019-11-26 02:21:34
Below is an example of adding two panels to a frame. Only one panel (the 2nd, red panel) appears. Why does the first panel disappear? import java.awt.*; import javax.swing.*; import javax.swing.border.EmptyBorder; public class DisappearingPanelInFrame { DisappearingPanelInFrame() { JFrame f = new JFrame(this.getClass().getSimpleName()); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.add(new ColoredPanel(Color.GREEN)); f.add(new ColoredPanel(Color.RED)); f.pack(); f.setVisible(true); } public static void main(String[] args) { Runnable r = new Runnable() { @Override public void run() {

How returns XxxSize from JComponent(s) added to the JLabel

好久不见. 提交于 2019-11-26 02:15:02
问题 how can I correctly returns XxxSize from JComponent(s) added to the JLabel 1st. figure >> lets LayoutManager works like as for JPanel, JLabel returns Size(0, 0) 2nd. figure >> added some PreferredSize to the JLabel 3rd. figure >> calculated PreferredSize from JComponent(s) added to the JLabel 4th. figure >> lets LayoutManager works changed JLabel to JPanel, now LayoutManager correctly calculated Dimension without using any XxxSize notice sice there is used Nimbus L&F, same output is there for

JPanel & components change position automatically

雨燕双飞 提交于 2019-11-26 02:03:57
问题 Hi I am working on swing application but I am facing one problem. When I first run application JPanel is positioned at proper position where I decided to set with components inside. But problem occur when I minimize & again maximize frame window jpanel automatically changes it\'s position. Below images shows that difference As we can see on second image components changes it\'s position automatically. For this I written below code, jpanel_addPurchase = new JPanel(); jpanel_addPurchase

Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?

帅比萌擦擦* 提交于 2019-11-26 01:17:12
问题 Several times I\'ve been criticized for having suggested the use of the following methods: setPreferredSize setMinimumSize setMaximumSize on Swing components. I don\'t see any alternative to their use when I want to define proportions between displayed components. I have been told this: With layouts the answer is always the same: use a suitable LayoutManager I have searched the web a little bit, but I haven\'t found any comprehensive analysis of the subject. So I have the following questions:

How to add JTable in JPanel with null layout?

拟墨画扇 提交于 2019-11-26 01:17:07
问题 I want to add JTable into JPanel whose layout is null . JPanel contains other components. I have to add JTable at proper position. 回答1: Nested/Combination Layout Example The Java Tutorial has comprehensive information on using layout managers. See the Laying Out Components Within a Container lesson for further details. One aspect of layouts that is not covered well by the tutorial is that of nested layouts, putting one layout inside another to get complex effects. The following code puts a