grid-layout

Components in GridLayout wit JPanel fills the grid incorrectly

♀尐吖头ヾ 提交于 2020-01-15 23:05:47
问题 I am trying to prevent the GridLayout in a JPanel from filling the cells entirely and ignoring any setSize of the components i am using this code: import javax.swing.*; import java.awt.*; public class GrideComponents{ public static void main(String[] args) { JFrame frame = new JFrame("Laying Out Components in a Grid"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new GridLayout(5,2,0,0)); panel.add(new JLabel("Enter name")); JTextField a = new JTextField(5);

Components in GridLayout wit JPanel fills the grid incorrectly

自古美人都是妖i 提交于 2020-01-15 23:05:09
问题 I am trying to prevent the GridLayout in a JPanel from filling the cells entirely and ignoring any setSize of the components i am using this code: import javax.swing.*; import java.awt.*; public class GrideComponents{ public static void main(String[] args) { JFrame frame = new JFrame("Laying Out Components in a Grid"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new GridLayout(5,2,0,0)); panel.add(new JLabel("Enter name")); JTextField a = new JTextField(5);

GridLayout and number of rows and columns

邮差的信 提交于 2020-01-14 12:42:08
问题 Does GridLayout ever not honor the number of rows and columns you've specified if you don't fill it completely? I'm creating a GridLayout with 3 rows and 4 columns. However, I'm only adding 9 components. It ends up showing me these 9 components in a 3x3 grid, rather than a 3x4 grid (with only 1 component on the third row (and two blanks)). 回答1: Just fill empty cells with empty items (like a JLabel ), eg: class MyFrame extends JFrame { MyFrame() { setLayout(new GridLayout(3,4)); for (int i = 0

How can I make a div span multiple rows and columns in a grid?

佐手、 提交于 2020-01-13 09:53:55
问题 Building off of a previous question, I'm trying to add bigger blocks to my grid layout. In the last question, I needed to have a div span multiple rows. The problem now is that I need a div to span multiple rows and columns . If I have a five-element row , how could I put bigger elements in the middle of it? (as float puts it naturally on the side). Here's an example snippet: #wrapper{ width: 516px; } .block{ display: inline-block; width: 90px; height: 50px; margin: 5px; background-color: red

Adding JPanels through a loop

♀尐吖头ヾ 提交于 2020-01-11 11:26:08
问题 Made it work! Thank you guys! The code follows. I used BoxLayout since I thought it'd be ideal for stacking questions one on top of the other, but now I got issues with the layout... When I stack several questions the question panels start overlapping. Any thoughts? panels1 = new MultipleChoice[5]; setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); for(int i=0; i<4; i++){ panels1[i]= new MultipleChoice(); panels1[i].setAlignmentX(CENTER_ALIGNMENT); add(panels1[i]); } setVisible(true); I'm

How to reduce columns from three to two without it moving below - bootstrap

醉酒当歌 提交于 2020-01-06 15:51:38
问题 I am trying to use this piece of html/css http://bootsnipp.com/snippets/featured/grid-columns-divider for a line divider. However; when I try to get rid of one column and have it just as 2 column with a 25%/75% split it glitches out and makes it go below it and the line divider disappears. Also, how would I get the line divider to not be as near the top as it currently is, I want there to be a gap at the top. /* Tablet and bigger */ @media ( min-width: 768px ) { .grid-divider { position:

How to reduce columns from three to two without it moving below - bootstrap

霸气de小男生 提交于 2020-01-06 15:51:34
问题 I am trying to use this piece of html/css http://bootsnipp.com/snippets/featured/grid-columns-divider for a line divider. However; when I try to get rid of one column and have it just as 2 column with a 25%/75% split it glitches out and makes it go below it and the line divider disappears. Also, how would I get the line divider to not be as near the top as it currently is, I want there to be a gap at the top. /* Tablet and bigger */ @media ( min-width: 768px ) { .grid-divider { position:

JLabel in GridLayout

浪尽此生 提交于 2020-01-04 03:00:34
问题 How to add JLabel out of the GridLayout ? I have an 8x8 grid layout. Container content = getContentPane(); content.setLayout(new GridLayout(8, 8,2,2)); for (int f = 0; f < btnArr.length; f++){ for (int s = 0; s < btnArr.length; s++){ btnArr[f][s] = new JButton(); btnArr[f][s].addActionListener(this); content.add(btnArr[f][s]); btnArr[f][s].setBackground(randomColor()); } } 回答1: import java.awt.*; import javax.swing.*; class SimpleNestedLayout { public static void main(String[] args) {

Android margin between buttons in grid layout

一世执手 提交于 2020-01-03 13:33:03
问题 I'm trying to create a grid layout containing buttons but by default there is a space between these buttons and I don't need that. The .xml file looks like this: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center"> <HorizontalScrollView android:id="@+id/HorizontalScrollView" android:layout_width="wrap_content" android:layout_height=

JProgressbar width using Grid/FlowLayout

社会主义新天地 提交于 2020-01-03 13:00:29
问题 I'm working on a downloader which looks like this at the moment: The JFrame uses a BorderLayout. In the NORTH, I have a JPanel(FlowLayout). In the SOUTH there is also a JPanel(FlowLayout), in the WEST I just have a JTextArea (in a JScrollPane). This is all shown correctly. However, in the EAST I currently have a JPanel(GridLayout(10, 1)). I want to show up to 10 JProgressBars in the EAST section which are added and removed from the panel dynamically. The problem is, I can not get them to look