#1 28. Mai 2010 Zuletzt von einem Moderator bearbeitet: 15. April 2017 GridBagLayout Problem Hallo liebe RR-ler und GUI Profis ;-), ich habe da ein sehr großes Problem... Und zwar benutze ich den GridBagLayout Manager. {img-src: //img715.imageshack.us/img715/7807/zwischenablage01jd.jpg} Ich möchte dass der Platz zwischen der schrift oben und den Buttons minimal bzw = 0 ist. Wie stelle ich dasss an? SO habe ich mein Constraints gemacht: private void buildConstraints(GridBagConstraints gbc,int x, int y, int w, int h, int wx, int wy, int fill, int anchor){ gbc.gridx = x; // start cell in a row gbc.gridy = y; // start cell in a column gbc.gridwidth = w; // how many column does the control occupy in the row gbc.gridheight = h; // how many column does the control occupy in the column gbc.weightx = wx; // relative horizontal size gbc.weighty = wy; // relative vertical size gbc.fill = fill; // the way how the control fills cells gbc.anchor = anchor; // alignment } // Dass sind die zwei überschriften: getContentPane().add(HauptPnl); buildConstraints(gbc, 0, 0, 1, 1, 1,1, GridBagConstraints.ABOVE_BASELINE, GridBagConstraints.NORTH ); gbl.setConstraints(jbl1, gbc); HauptPnl.add(jbl1); buildConstraints(gbc, 2, 0, 1, 1, 1,1, GridBagConstraints.ABOVE_BASELINE, GridBagConstraints.NORTH ); gbl.setConstraints(jbl2, gbc); HauptPnl.add(jbl2); // Und dass sind die 2x 100 Buttons: pnl1.setLayout(new GridLayout(10,10)); pnl2.setLayout(new GridLayout(10,10)); buildConstraints(gbc, 0, 2, 1, 1, 1,1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); gbl.setConstraints(pnl1, gbc); HauptPnl.add(pnl1); buildConstraints(gbc, 2, 2, 1, 1, 1,1, GridBagConstraints.BOTH, GridBagConstraints.NORTHEAST); gbl.setConstraints(pnl2, gbc); HauptPnl.add(pnl2); } Soo und wie stelle ich es an dass die Buttons quadratisch bleiben und dass sich der Abstand von "Überschrift" minimiert? LG Labernet + Multi-Zitat Zitieren
#2 29. Mai 2010 AW: GridBagLayout Problem niemand der mir helfen kann? Ich muss dass ding innerhalb von 2 wochen fertig haben. Ist eine Seminararbeit. Thema Schiffe-Versenken. + Multi-Zitat Zitieren
#3 29. Mai 2010 AW: GridBagLayout Problem wie wärs wenn du einfach ein borderlayout über das ganze legst und das hauptlayout dann wieder in borders bzw gridlayouts aufteilst? ich hab vom gridbaglayout noch nie was gehört.. die buttons würd ich dann im hauptlayout in den center schieben(eigenes gridlayout) und die schrift in den north.(würd auch n 2x1 gridlayout nehmen) + Multi-Zitat Zitieren
#4 29. Mai 2010 AW: GridBagLayout Problem Ok thx... werds mal ausprobieren. Sag mal gibt es ein tool oder PlugIn für Eclipse, mit drag and drop funktion oder soo? Also für Swing Klassen? Gruß Labernet + Multi-Zitat Zitieren
#5 29. Mai 2010 AW: GridBagLayout Problem Drag-and-Drop hab ich auf die schnelle gefunden, scheint recht nützlich zu sein(vor allem die tabelle) + Multi-Zitat Zitieren
#6 29. Mai 2010 AW: GridBagLayout Problem netbeans ist in sachen oberfläche sehr gut. ich mache die oberflächen dort und in eclipse das backend + Multi-Zitat Zitieren
#7 29. Mai 2010 AW: GridBagLayout Problem Ja, in Netbeans gibt es einen GUI Builder wo du dir das zusammenklicken kannst. Vorrausgesetzt man kann GUI Programmierung schon, dann ist dieses Feature recht praktisch. + Multi-Zitat Zitieren