troubleshooting Question

How do I create a Group Layout which works

Avatar of Reynold Nangawe
Reynold Nangawe asked on
Java
2 Comments1 Solution76 ViewsLast Modified:
I have created a group layout as defined bellow but it doesn't work, I try to add groups to bigger groups, what am I doing wrong? Can anyone help?

search = new JTextField();
				srch = new JButton ("Search");
				
				JLabel disptitle = new JLabel("");
				BufferedImage buttonIcon = ImageIO.read(new File("Graphics/back.jpg"));
				BufferedImage buttonIcon2 = ImageIO.read(new File("Graphics/home.jpg"));
				BufferedImage buttonIcon3 = ImageIO.read(new File("Graphics/forward.jpg"));
				
				bck = new JButton (new ImageIcon(buttonIcon));
				frw = new JButton (new ImageIcon(buttonIcon3));
				hme = new JButton (new ImageIcon(buttonIcon2));
				
				JTextArea textArea = new JTextArea (16, 58);
				textArea.setSize(400,400);
				JScrollPane scroll = new JScrollPane (textArea,
				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
				System.out.println ("Test b");
				JTextArea textArea2 = new JTextArea (16, 58);
				textArea.setSize(400,400);
				JScrollPane scroll2 = new JScrollPane (textArea2,
				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
				
				GroupLayout.SequentialGroup navigation = layout.createSequentialGroup();
				navigation.addComponent(bck);
  		  		navigation.addComponent(frw);
				navigation.addComponent(hme);
				
				GroupLayout.SequentialGroup searche = layout.createSequentialGroup();
				searche.addComponent(search);
  		  		searche.addComponent(srch);
				
				GroupLayout.SequentialGroup naviga = layout.createSequentialGroup();
				naviga.addComponent(disptitle);
  		  		naviga.addGroup(navigation);
				
				GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup();
  		  		leftToRight.addGroup(searche);
  		  		leftToRight.addGroup(naviga);
				
  				GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup();
    			GroupLayout.ParallelGroup rowTop = layout.createParallelGroup();
    			rowTop.addGroup(searche);
				rowTop.addGroup(naviga);
    			topToBottom.addGroup(rowTop);
    		System.out.println ("Test c");	
				GroupLayout.SequentialGroup iga = layout.createSequentialGroup();
				iga.addComponent(scroll);
				GroupLayout.SequentialGroup igade = layout.createSequentialGroup();
				igade.addComponent(scroll2);
				
				
				GroupLayout.ParallelGroup rowBot = layout.createParallelGroup();
    			rowBot.addGroup(iga);
    			rowBot.addGroup(igade);
    			topToBottom.addGroup(rowBot);
	
  			  	layout.setHorizontalGroup(navigation);
  		 	 	layout.setHorizontalGroup(searche);
  		 	 	layout.setHorizontalGroup(naviga);
				layout.setHorizontalGroup(leftToRight);	
				layout.setHorizontalGroup(topToBottom);
  		 	 	
				window.add(panel);
				System.out.println ("Test A");
				window.pack();
    			window.setVisible(true);
			
ASKER CERTIFIED SOLUTION
Manikandan Thiagarajan
Senior consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros