Avatar billede sen8or_slettet Nybegynder
27. januar 2000 - 12:33 Der er 1 løsning

Gridbag Layout

My problem is as follows: I´m making a gridbag with 3 rows and in the second row I have to split up the cells or insert a panel. That´s because of the things I´m putting in ém. Choosing the panel leads me to following question: Where am I going to declare the panel and where should the gridbag in the panel in the gridbag (!) be placed?



import java.awt.*;
public class Rapport extends
java.applet.Applet
{
        Panel Pane = new Panel();
        void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy)
        {
            gbc.gridx = gx;
            gbc.gridy = gy;
            gbc.gridwidth = gw;
            gbc.gridheight = gh;
            gbc.weightx = wx;
            gbc.weighty = wy;
            add(Pane);
        }
                public void init()
                {
        GridBagLayout gridbag = new GridBagLayout();
        GridBagConstraints constraints = new GridBagConstraints();
        setLayout(gridbag);
        Pane.setLayout(gridbag)
        //label
        buildConstraints(constraints, 0, 0, 1, 1, 33, 0);
        constraints.fill = GridBagConstraints.BOTH;
        constraints.anchor = GridBagConstraints.WEST;
        Label label01 = new Label("Kundenummer", Label.LEFT);
        gridbag.setConstraints(label01, constraints);
        add(label01);
                .
                .
            //Panel 
        buildConstraints(constraints, 0, 0, 1, 1, 50, 0);
        constraints.fill = GridBagConstraints.BOTH;
        constraints.anchor = GridBagConstraints.WEST;
        Label PanLabel1 = new Label("1", Label.LEFT);
        gridbag.setConstraints(PanLabel1, constraints);
        Pane.add(PanLabel1);
        //Panel
        buildConstraints(constraints, 1, 0, 1, 1, 50, 0);
        constraints.fill = GridBagConstraints.BOTH;
        constraints.anchor = GridBagConstraints.WEST;
        Label PanLabel2 = new Label("2", Label.LEFT);
        gridbag.setConstraints(PanLabel2, constraints);
        Pane.add(PanLabel2);
            //Label
        buildConstraints(constraints, 2, 0, 1, 1, 33, 0);
        constraints.fill = GridBagConstraints.BOTH;
        constraints.anchor = GridBagConstraints.WEST;
        Label label12 = new Label("            Dato                    Reparatør", Label.LEFT);
        gridbag.setConstraints(label12, constraints);
        add(label12);
                .
                .

Avatar billede sen8or_slettet Nybegynder
28. januar 2000 - 13:15 #1
Jeg har fundet svar, andetsteds...

SEN8OR
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester