Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-19-2009, 03:36 AM
Member
 
Join Date: Apr 2009
Posts: 11
Rep Power: 0
Wolverine is on a distinguished road
Default [SOLVED] I share BoxLayout with Conteiner but it doesn' t work
Hi know that BoxLayout need to be shared with a Conteiner(JFrame),but so i don't see the panel inside.I put my codes so you understand better:

Code:
   package grafica;

import java.awt.GridBagLayout;


public class Finestra {

	/**
	 * @author Carmine
	 */
	public static void main(String[] args) {
		Start finestraApplicazione = new Start();
		finestraApplicazione.setVisible(true);
	}

}


package grafica;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;


public class Start extends JFrame {
	
	private Pannellodestro pannellodestro;
	private ListaRosa lista;
	private FinestraFormazione ff;	
	
	
		public Start(){
		  super("Gestione squadra");
		  setSize(new Dimension(1270,750));
		  Container cp = getContentPane();
		
		  JPanel principale = new JPanel();	
		  
		  principale.setLayout(new BoxLayout(principale, BoxLayout.LINE_AXIS));
		  principale.add(Box.createHorizontalStrut(500));
	      principale.add(new JLabel("Other stuff goes here"));
	      principale.add(Box.createHorizontalStrut(400));
	    
		  pannellodestro = new Pannellodestro();
		  JPanel pannellocentrale = new JPanel();
		  JPanel pannellotabella = new JPanel();
		
		  principale.add(pannellodestro);
		  //principale.add(pannellocentrale);
		  //principale.add(pannellotabella);
		  
		  
		  cp.setLayout(new BoxLayout(cp, BoxLayout.LINE_AXIS));
		  cp.add(Box.createHorizontalStrut(500));
		  //cp.add(new JLabel("Other stuff goes here"));
		  cp.add(Box.createHorizontalStrut(400));
		  cp.add(principale);	
		  
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          pack();
          setLocationRelativeTo(null);
          
	}
}

package grafica;

import java.util.ArrayList;

import javax.swing.*;
import javax.swing.SpringLayout;
import java.awt.*;
import java.awt.event.*;

import Gestione.*;

public class Pannellodestro extends JPanel {
	
	private static final String[] LIST_STRINGS = { 
	    "Portiere", "Difensore",
	    "Centrocampista", "Attaccante" 
	};
	
	private static final String NOME_GIOCATORE = "nome giocatore";
	private static final String SCELTA_RUOLO = "scelta ruolo";
	private static final int COMBO_COUNT = 25;
	
	private JPanel principale = new JPanel();
	private JComboBox[] list = new JComboBox[COMBO_COUNT];
	private JTextField[] nGiocatori = new JTextField[COMBO_COUNT];
	/**
	 * Costruttore che mi realizza i pannelli con le JTextField in cui inserire i nomi dei giocatori e le JComboBox 
	 * con cui si sceglie il ruolo
	 * @param è il titolo del pannello corrispondente
	 */
	public Pannellodestro() {
		
	    JPanel destro = new JPanel(new BorderLayout());
		JPanel gridPanel = new JPanel(new GridLayout(0, 2, 0, 0));
	    JPanel topPanel = new JPanel(new  GridLayout(0, 2, 0, 0));
	    JPanel bottomPanel = new JPanel(new GridLayout(0, 2, 0, 0));
	    
	   
	    
	    topPanel.add(new JLabel(NOME_GIOCATORE, SwingConstants.CENTER));
	    topPanel.add(new JLabel(SCELTA_RUOLO, SwingConstants.CENTER));
	    
	    for (int i = 0; i < list.length; i++) {
	      nGiocatori[i] = new JTextField(5);
	      list[i] = new JComboBox(LIST_STRINGS);
	      list[i].setEditable(false);
	      
	      gridPanel.add(nGiocatori[i]);
	      gridPanel.add(list[i]);
	    }
	   
	    bottomPanel.add(new JButton("Salva Rosa"));
	    bottomPanel.add(new JButton("Carica Rosa"));
	    
	    JScrollPane gridScroll = new JScrollPane(gridPanel);
	    Dimension gsSize = gridScroll.getPreferredSize();
	    gridScroll.setPreferredSize(new Dimension(gsSize.width + 15, 500));
	    
	    
	    destro.add(topPanel, BorderLayout.PAGE_START);
	    destro.add(gridScroll, BorderLayout.CENTER);
	    destro.add(bottomPanel,BorderLayout.SOUTH);
	    
}	    

}
when i lunch the class Finestra i just see a little window and nothing else...

Thanks in advance for help!!!
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 05-19-2009, 04:11 AM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
Default
shared?

How to Use BoxLayout (The Java™ Tutorials > Creating a GUI with JFC/Swing > Laying Out Components Within a Container)
__________________
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-19-2009, 05:51 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,463
Rep Power: 8
Fubarable is on a distinguished road
Default
I gave you the link for the layout manager tutorials just yesterday. I strongly urge you to read them and to study them before venturing forward. This would include studying and running the sample programs that come with the tutorials. Best of luck.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-19-2009, 06:35 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Originally Posted by Fubarable View Post
I gave you the link for the layout manager tutorials just yesterday. I strongly urge you to read them and to study them before venturing forward. This would include studying and running the sample programs that come with the tutorials. Best of luck.
OP, please pay your attention on this. We couldn't see any effort on what Fubarable says in a previous thread, about the layout. He gives you a nice link, all about the layouts. All what you need is there.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-19-2009, 01:40 PM
Member
 
Join Date: Apr 2009
Posts: 11
Rep Power: 0
Wolverine is on a distinguished road
Default
You are right...but before i put post i had read link about Tutorial of BorderLayout...but i'dont turn out to found mistake.Now i'm solved it...it was simple that in the costructor

Code:
----
 public Pannellodestro() {
		
	    JPanel destro = new JPanel(new BorderLayout());

----
i forgot to add the panel "destro"
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-21-2009, 05:21 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
You can find another useful constructor for BorderLayout as well, handling the space between controls.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 05-21-2009, 07:13 PM
Member
 
Join Date: Apr 2009
Posts: 11
Rep Power: 0
Wolverine is on a distinguished road
Default
"You can find another useful constructor for BorderLayout as well, handling the space between controls."

Eranga you means with the costructor " BorderLayout()"
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 05-22-2009, 04:57 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
I\m talking about this.

Code:
BorderLayout(int hgap, int vgap)
BorderLayout (Java 2 Platform SE v1.4.2)
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] my programm doesn´t run like it shoud be. AlejandroPe New To Java 3 04-07-2009 01:42 PM
[SOLVED] Possible to have two BoxLayout in same area of BorderLayout? mainy AWT / Swing 4 02-16-2009 10:52 PM
How to Connect Share Point Using Java jazz2k8 New To Java 7 07-15-2008 07:39 PM
Got an Idea, Just Share it! james Java Announcements 0 03-18-2008 01:09 PM
HashMap to share OutputStream gabriel Advanced Java 1 08-06-2007 06:47 PM


All times are GMT +2. The time now is 07:22 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org