grouplayout

How to set Jframe Background Image in GroupLayout Java

喜夏-厌秋 提交于 2020-01-11 06:15:42
问题 Am trying to set a background image for my frame but it does not work. I tried this link: Setting background images in JFrame The code: setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("/Images/about.png"))))); I tried adding the above code to my Contentpane but it does not work. public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { MainMenu frame = new MainMenu(); frame.setVisible(true); } catch (Exception e) { e

Can Components be added to groups in GroupLayout dynamically?

萝らか妹 提交于 2019-12-25 08:27:42
问题 Can Component s be added to groups in GroupLayout dynamically, after setHorizontalGroup() and setVerticalGroup() have been called, without resetting the layout? I'm working on the GUI to a project that will help students find the best way to put together their weekly class schedules. This involves inputting information regarding class times, etc., for an unknown number of classes. Of course, I can't just add an arbitrarily large number of forms for the user to put information into and say "no

JTable: Adding one to a JPanel, and it not displaying itself

ぃ、小莉子 提交于 2019-12-24 12:43:04
问题 It's Monday morning where I am, which means it's time for me to fail at Java Swing! But in all seriousness, I cannot figure out why my dynamically created JTable refuses to show itself once added to a JPanel on a JFrame, and would greatly appreciate any help in isolating this troublesome problem. As you can see from the code, I've called a dozen different methods, but can't seem to get the right one to get it to display...perhaps I am missing one? /* * To change this template, choose Tools |

GroupLayout: Vertical and Horizontal Groups

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 12:27:14
问题 I'm attempting to create a small Jpanel with a GroupLayout infront of it. Having followed the documentation as much as possible as well as looked at a number of StackOverflow questions, I'm still stuck. The error is as follows: Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: javax.swing.JButton[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.5,border=com.apple.laf.AquaButtonBorder$Dynamic@5eef2e7c,flags=288,maximumSize=,minimumSize=,preferredSize=,defaultIcon=

Building GUI using GroupLayout in Java

我与影子孤独终老i 提交于 2019-12-18 16:58:20
问题 I need to build a GUI using GroupLayout (not other layouts). The GUI will look like the following: ---------------------------- | field 1 field 2 field 3 | | FFIEEELLLDD4 FIELDDDDDD5 | | FIEEEEEEEEEEEEEEELDDDD 6 | _____________________________ Fields 1 - 3 take 1 length each, field 4 and 5 take 1.5 length each, and field 6 takes 3 length. The three groups are aligned both at the beginning and the end. I've been referring to this http://docs.oracle.com/javase/tutorial/uiswing/layout/group.html

How to iteratively add Components to a Swing GroupLayout ParallelGroup?

♀尐吖头ヾ 提交于 2019-12-18 08:26:19
问题 Is there a way to iterate over a List of Components and add them to a ParallelGroup in Swing GroupLayout? It seems difficult because there is no method to get hold of the ParallelGroup. Here is the code generating a List of Components (in this case, JCheckBoxes). List<JCheckBox> listCustomiseJCB = new ArrayList<>(); for (int w = 0; w < initialCMTableColumns.size(); w++) { String heading = (String)initialCMTableColumns.get(w).getHeaderValue(); listCustomiseJCB.add(new JCheckBox(heading)); }

How to iteratively add Components to a Swing GroupLayout ParallelGroup?

孤人 提交于 2019-12-18 08:25:58
问题 Is there a way to iterate over a List of Components and add them to a ParallelGroup in Swing GroupLayout? It seems difficult because there is no method to get hold of the ParallelGroup. Here is the code generating a List of Components (in this case, JCheckBoxes). List<JCheckBox> listCustomiseJCB = new ArrayList<>(); for (int w = 0; w < initialCMTableColumns.size(); w++) { String heading = (String)initialCMTableColumns.get(w).getHeaderValue(); listCustomiseJCB.add(new JCheckBox(heading)); }

Java GroupLayout Exception

风流意气都作罢 提交于 2019-12-12 03:00:04
问题 public class Grouplayout implements Runnable { public static void main(String[] args) { SwingUtilities.invokeLater(new Grouplayout()); } @Override public void run() { JFrame jFrame = new JFrame(); GroupLayout layout = new GroupLayout(jFrame.getContentPane()); jFrame.getContentPane().setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); JLabel jLabel1 = new JLabel("a"); JLabel jLabel2 = new JLabel("b"); JLabel jLabel3 = new JLabel("c"); JLabel jLabel4 =

I want to align labels and textfields next to one other and all the buttons in a single row; how can i do it?

不想你离开。 提交于 2019-12-11 19:46:52
问题 I'm sorry for not giving much information; I'm new to Java. Please can you help me with this code? I want to align labels and textfields next to one other and all the buttons in a single row. How can i do this? Here's how I'm creating a GroupLayout: javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); Here's how I'm creating a horizontal group: layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment

IllegalStateException in a GroupLayout

寵の児 提交于 2019-12-11 19:24:08
问题 I use a GroupLayout for my panel : GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup() .addComponent(title_panel) .addComponent(subtitle_panel) ); layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(title_panel) .addComponent(subtitle_panel) ); Even if I define both horizontal AND vertical groups, it still gives me a java.lang.IllegalStateException But not always. Sometimes it does it, sometimes it does