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);
			

Open in new window

ASKER CERTIFIED SOLUTION
Manikandan Thiagarajan
Senior consultant

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

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 2 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 2 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004