layout-manager

How to make a JTable fill entire available space?

三世轮回 提交于 2020-01-06 13:56:20
问题 I want to created a panel with a table, which fills the entire available space. I do this using following code: public class MyFrame extends JFrame { public EconomyFrame() throws HeadlessException { super("..."); final JTabbedPane tabbedPane = new JTabbedPane(); add(tabbedPane); final JPanel companiesPanel = new JPanel(); final CompaniesTableModel companiesModel = new CompaniesTableModel (ApplicationStateSingleton.INSTANCE.getPersistence().getCompanies()); final JTable companiesTable = new

How to make a JTable fill entire available space?

雨燕双飞 提交于 2020-01-06 13:55:13
问题 I want to created a panel with a table, which fills the entire available space. I do this using following code: public class MyFrame extends JFrame { public EconomyFrame() throws HeadlessException { super("..."); final JTabbedPane tabbedPane = new JTabbedPane(); add(tabbedPane); final JPanel companiesPanel = new JPanel(); final CompaniesTableModel companiesModel = new CompaniesTableModel (ApplicationStateSingleton.INSTANCE.getPersistence().getCompanies()); final JTable companiesTable = new

How to apply another LayoutManager to a JComboBox? (multi-column JComboBox attempt)

笑着哭i 提交于 2020-01-06 02:33:44
问题 I'm trying to make a multi-column JComboBox. I've looked around quite a bit and it seems to be a very tricky thing to do. Unless many people, I'm not interested in having a table (where you select a row): I need to eliminate the scroll bar in the JComboBox and, in order to achieve this, I want to lay its items in a multi-column list instead of having them in only one column. My best bet so far was to do this: JComboBox dropdown = new JComboBox(validValues); CellRendererPane crp =

GridbagLayout seems to be ignoring component sizes

旧城冷巷雨未停 提交于 2020-01-06 01:44:14
问题 I am using GridBagLayout for the first time. I have a JFrame which has 2 panel's inside. The frame is of width 1200 and height 800. The left most JPanel has the width of 800 and height of 800. The right most panel has the width of 400 and height of 800. When they are rendering using GridBagLayout they are both being shown with equal size. This is the code: public class DisplayFrame extends JFrame { public DisplayFrame() { //simple inheritance. super(title); setSize(new Dimension(1200, 800));

Swing layout manager/solution to replace dynamically created and nested split panes?

萝らか妹 提交于 2020-01-05 07:38:08
问题 I'm working on a text editor in which the user is free to divide the editor window vertically or horizontally any number of times (ie, into any number of panes). A single window can be divided both vertically and horizontally (for example, 2 rows, one which contains 3 columns, etc). Each pane contains a JTextArea inside a JScrollPane and a status bar. My approach thus far has been to use nested JSplitPanes. I've struggled to arrange the split pane dividers so that the space in the window is

Swing layout manager/solution to replace dynamically created and nested split panes?

本小妞迷上赌 提交于 2020-01-05 07:36:33
问题 I'm working on a text editor in which the user is free to divide the editor window vertically or horizontally any number of times (ie, into any number of panes). A single window can be divided both vertically and horizontally (for example, 2 rows, one which contains 3 columns, etc). Each pane contains a JTextArea inside a JScrollPane and a status bar. My approach thus far has been to use nested JSplitPanes. I've struggled to arrange the split pane dividers so that the space in the window is

JScrollBar Doesn't Do Anything

。_饼干妹妹 提交于 2020-01-05 07:08:17
问题 I'm trying to put a vertical JScrollBar on top of a JPanel. I can add the scoll bar easily enough, but when I run the program, my scroll bar doesn't have any effect. I can drag it up and down, but the contents of the JPanel don't move. I've read all what I can find about how to do this, and it seems very straightforward, but I'm obviously missing something. Please note that my JPanel layout is set to NULL. Here is the relevant code. Thanks! public JDlgResults(ArrayList<AnsweredProblem>

Increasing distance from top of JPanel

爱⌒轻易说出口 提交于 2020-01-04 14:23:28
问题 I'm trying to increase the distance of my JButtons from the top of my Panel to make it more visually appealing, i've tried using an invisible button but have had no luck. public class SimpleBorder { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(500,500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border etched = (Border) BorderFactory.createEtchedBorder(); String[] items = {"A", "B", "C", "D"}; JList list = new JList(items); JTextArea text =

JButtons inside JPanels, fill up the whole panel

痞子三分冷 提交于 2020-01-04 06:31:30
问题 I've been struggling to set a specific size to a button inserted into a JPanel with a GridLayout. The button always fills up the whole panel, whereas if I remove the gridlayout, the button won't have the same behavior. any hints? package panels; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing

JPanel and JButton, cannot figure how to layout 2 simple buttons

和自甴很熟 提交于 2020-01-04 05:26:35
问题 i am starting with JPanel and i am trying to put 2 simple buttons on a frame, i was able to put the buttons but not position them, here is my code: JFrame frame = new JFrame(); frame.setSize(500,500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton but = new JButton("text"); JButton but2 = new JButton("list"); JPanel panel= new JPanel(new GridLayout(1, 2)); panel.setSize(100, 100); panel.add(but); panel.add(but2); frame.add(panel); frame.setVisible(true); and here is a sketch of