2010-08-20 12 views
6

पर शीर्ष मार्जिन क्या जेपीनल में 0 मार्जिन/पैडिंग जोड़ने का कोई तरीका है, इसलिए यह मानी जाने वाली WHOLE स्क्रीन को फिट करता है? (? पैनल के ऊपर कम जगह देखें कि यह यही कारण है कि कवर नहीं करता है और साथ ही?) see the space above?0 जेपीनेल

यहाँ जिस तरह से यह सेटअप है:

यहाँ है कि मैं क्या बात कर रहा हूँ है

 labelStatus = new JLabel("\n\nSorry, the server crashed!"); 

     labelStatus.setForeground(Color.WHITE.brighter()); 
     statusPanel = new JPanel(); 
     statusPanel.setBackground(Color.RED.darker()); 
     statusPanel.add(labelStatus); 
     statusPanel.setPreferredSize(new Dimension(513,352)); 

और इस यह कैसे iniated हो जाता है:

} catch (Exception rwe) { 
        // System.exit(0); 
        game.add(statusPanel); 
        game.remove(yPanel); 
        game.remove(xPanel); 
        game.remove(roomPanel); 
        game.remove(userPanel); 
        game.remove(titlePanel); 
        game.remove(introPanel); 
      statusPanel.setOpaque(true); 
      labelStatus.setVisible(true); 
        System.out.println("Server went down -- crap!"); 
        c.append("\nServer crashed!"); 
        rwe.printStackTrace(); 
      } 

तो .. कैसे मुझे लगता है कि छोटा अंतराल ठीक करते हैं?

उत्तर

6

डिफ़ॉल्ट रूप से, सभी कंटेनर लेआउट प्रबंधक FlowLayout का उपयोग करते हैं। FlowLayout घटकों को अलग करने के लिए एक hgap और vgap निर्दिष्ट करता है। इसे आज़माएं:

 
((FlowLayout)game.getLayout()).setVgap(0); 

हालांकि, यह अजीब बात है कि बाईं ओर कोई क्षैतिज अंतर नहीं है।

संबंधित मुद्दे