Example usage for java.awt GridBagLayout GridBagLayout

List of usage examples for java.awt GridBagLayout GridBagLayout

Introduction

In this page you can find the example usage for java.awt GridBagLayout GridBagLayout.

Prototype

public GridBagLayout() 

Source Link

Document

Creates a grid bag layout manager.

Usage

From source file:de.juwimm.cms.gui.admin.PanUnitGroupPerUser.java

void jbInit() throws Exception {
    this.setLayout(new GridBagLayout());

    this.unitPickData = new PickListData();
    this.unitPickData.setLeftLabel(rb.getString("panel.admin.tab.units.assigned"));
    this.unitPickData.setRightLabel(rb.getString("panel.admin.tab.units.all"));
    this.groupPickData = new PickListData();
    this.groupPickData.setLeftLabel(rb.getString("panel.admin.tab.groups.assigned"));
    this.groupPickData.setRightLabel(rb.getString("panel.admin.tab.groups.all"));
    this.panUnitPick = new PickListPanel(this.unitPickData);
    this.panGroupPick = new PickListPanel(this.groupPickData);
    this.btnSave.setText(rb.getString("dialog.save"));
    this.lblUser.setText(rb.getString("panel.login.username"));

    this.btnSave.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            save();/*ww w.java2 s . c o m*/
        }
    });

    this.tblUser = new JTable();
    JScrollPane scrollUser = new NoResizeScrollPane(tblUser);

    this.add(lblUser, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL, new Insets(10, 10, 5, 0), 0, 0));
    this.add(scrollUser, new GridBagConstraints(0, 1, 1, 2, 1.0, 1.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, new Insets(0, 10, 0, 0), 0, 0));
    this.add(btnSave, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST,
            GridBagConstraints.NONE, new Insets(10, 10, 10, 0), 0, 0));
    this.add(this.panUnitPick, new GridBagConstraints(1, 0, 1, 2, 2.0, 1.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, new Insets(0, 10, 0, 10), 0, 0));
    this.add(this.panGroupPick, new GridBagConstraints(1, 2, 1, 1, 2.0, 1.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, new Insets(0, 10, 0, 10), 0, 0));
}

From source file:org.bench4Q.console.ui.section.P_WIRTSection.java

/**
 * @param resources//from   w ww. j a va  2s.c  om
 * @param processControl
 * @param dispatcherFactory
 * @param TotalOrNot
 * @param agentIdentity
 * @param agentsCollection
 * @throws ConsoleException
 */
public P_WIRTSection(Resources resources, ProcessControl processControl,
        SwingDispatcherFactory dispatcherFactory, Boolean TotalOrNot, AgentIdentity agentIdentity,
        AgentsCollection agentsCollection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_swingDispatcherFactory = dispatcherFactory;

    this.TotalOrNot = TotalOrNot;
    m_agentIdentity = agentIdentity;

    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    testduring = -1;
    resultNumber = 0;

    wirt = new ResultSet[15];
    thiswirt = new ArrayList();

    this.setLayout(new GridBagLayout());

    this.setPreferredSize(new Dimension(550, 445));
    this.setMinimumSize(new Dimension(550, 445));

    picPanel = new PicPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1));

}

From source file:org.kepler.plotting.Plot.java

public void setScrolling(boolean scrolling) {

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 1;/* w ww . ja v a  2  s  .  c o m*/
    constraints.gridy = 1;

    if (panel == null) {
        // initialize panel
        panel = new JPanel(new GridBagLayout());
    } else {
        panel.removeAll();
    }
    // Now we have an empty panel

    Component graphComponent;
    chartPanel = new ChartPanel(chart);
    // System.out.println("Chart panel has been set: " + System.identityHashCode(chartPanel));
    if (scrolling) {
        JScrollPane scrollPane = new JScrollPane(chartPanel);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        graphComponent = scrollPane;
    } else {
        graphComponent = chartPanel;
    }

    panel.add(graphComponent, constraints);
}

From source file:Citas.FrameCita.java

public FrameCita()
        throws ClientProtocolException, IOException, JSONException, ParseException, java.text.ParseException {

    initComponents();//from   w w w  . j  av  a2  s. c o  m
    this.getContentPane().setLayout(new GridBagLayout());
    rutasLeer = new Leer();
    rutasAdd = new Add();
    medico = new Medico(2, 0, 3, 30); //MEDICO EN SESIOOON
    citas = new Citas[medico.cantidadDeCitasxDia(10, 30)];

    try {
        font = Font.createFont(Font.TRUETYPE_FONT, new File("Sertig.otf"));
        font = font.deriveFont(Font.BOLD, 11);
    } catch (FontFormatException ex) {
        Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex);
    }

    setTitle("Citas");

    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 0.5;
    gbc.weighty = 0.5;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    this.getContentPane().add(PanelCalendar, gbc);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 0.5;
    gbc.weighty = 1.0;
    this.getContentPane().add(PanelCita, gbc);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    gbc.gridheight = 2;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    this.getContentPane().add(PanelDetalle, gbc);

    ////////////////// PANEL DETALLES

    //Colores
    colorBackGround = new Color(hex("8FA8F6"));//Color de los BackGround 
    colorTextFields = new Color(hex("CDCBA6"));//Color de los JTextFields
    colorDelPapa = new Color(hex("2980b9"));//Color del backgorud del papa
    colorBotones = new Color(hex("2C3E50"));//Color d elos botonte
    colorActivo = new Color(hex("81CFE0"));//Color de los jTextFild cuando los activan
    //Colores

    //Inicializaciones

    this.setBackground(colorDelPapa);//Color del backgroud
    //BOTONES INICIALIZACION
    modificarB = new JButton("Modificar");
    eliminarB = new JButton("Eliminar");
    agregarB = new JButton("Agregar");
    atrasB = new JButton("Atras");
    buscarB = new JButton("Buscar");
    Botones = new JPanel(); //PAnel donde van los botones Agregar, Modificar y Eliminar
    BotonAtras = new JPanel(); //PAnel donde va el boton atras
    BotonBuscar = new JPanel(); //PAnel donde va el boton buscar
    agregarB.addActionListener(this);
    modificarB.addActionListener(this);
    eliminarB.addActionListener(this);
    atrasB.addActionListener(this);
    buscarB.addActionListener(this);
    // FIN BOTONES INICIALIZACION

    PanelCita.setLayout(new GridBagLayout());

    disenoBotones(modificarB);
    disenoBotones(eliminarB);
    disenoBotones(agregarB);
    disenoBotones(atrasB);
    disenoBotones(buscarB);
    PanelDetalle.setLayout(new GridBagLayout()); //Panel Pap (PanelDetalle)
    cambiarColorPanel(PanelCalendar, colorDelPapa);
    cambiarColorPanel(PanelCita, colorDelPapa);
    cambiarColorPanel(PanelDetalle, colorDelPapa);

    //LABELS
    horaCitas = new JLabel();
    fechaL = new JLabel("<HTML> Fecha &nbsp</HTML>");
    horaL = new JLabel("<HTML> Hora &nbsp</HTML>");
    nombreL = new JLabel("<HTML> Nombre &nbsp &nbsp </HTML>");
    apellidoL = new JLabel("<HTML> Apellido &nbsp &nbsp &nbsp</HTML>");
    cedulaL = new JLabel("<HTML> Cedula &nbsp &nbsp &nbsp &nbsp &nbsp</HTML>");
    direccionL = new JLabel("<HTML> Direccion &nbsp &nbsp</HTML>");
    motivosL = new JLabel("<HTML> Motivos &nbsp &nbsp &nbsp &nbsp</HTML>");
    telefonoCasaL = new JLabel("<HTML> Tlfn Casa&nbsp </HTML>");
    telefonoCelularL = new JLabel("<HTML> Tlfn Celular</HTML>");
    correoL = new JLabel("<HTML> Correo &nbsp &nbsp &nbsp</HTML>");

    font = font = font.deriveFont(Font.BOLD, 11);
    disenoLabel(horaCitas);
    disenoLabel(fechaL);
    disenoLabel(horaL);
    disenoLabel(nombreL);
    disenoLabel(apellidoL);
    disenoLabel(cedulaL);
    disenoLabel(direccionL);
    disenoLabel(motivosL);
    disenoLabel(telefonoCasaL);
    disenoLabel(telefonoCelularL);
    disenoLabel(correoL);

    //JTEXTFIELDS y TEXAREA

    fechaJ = new JTextField("");
    horaJ = new JTextField("");
    nombreJ = new JTextField("");
    apellidoJ = new JTextField("");
    cedulaJ = new JTextField("");
    direccionJ = new JTextField();
    motivosTA = new JTextArea("");
    telefonoCasaJ = new JTextField("");
    telefonoCelularJ = new JTextField("");
    correoJ = new JTextField("");
    //COLORES
    /*fechaJ.setBackground(colorTextFields);
    horaJ.setBackground(colorTextFields);
    nombreJ.setBackground(colorTextFields);
    apellidoJ.setBackground(colorTextFields);
    cedulaJ.setBackground(colorTextFields);
    direccionJ.setBackground(colorTextFields);
    motivosTA .setBackground(colorTextFields);
    telefonoCasaJ.setBackground(colorTextFields);
    telefonoCelularJ.setBackground(colorTextFields);
    correoJ.setBackground(colorTextFields);
    */
    //Aadir componentes al PanelDetalle
    GridBagConstraints constraints = new GridBagConstraints();

    //Caracteristicas globales del grid
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weighty = 1.0;
    constraints.insets.set(5, 0, 5, 10);
    //Fin Caracteristicas Globales del grid

    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    PanelDetalle.add(fechaL, constraints);

    constraints.gridx = 1; //Necesita estirarse
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1.0;
    PanelDetalle.add(fechaJ, constraints);
    constraints.weightx = 0.0;

    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    PanelDetalle.add(horaL, constraints);

    constraints.gridx = 1; //Necesita estirarse
    constraints.gridy = 1;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1.0;
    PanelDetalle.add(horaJ, constraints);
    constraints.weightx = 0.0;

    constraints.gridx = 0;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    PanelDetalle.add(nombreL, constraints);

    constraints.gridx = 1;//Necesita estirarse
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1.0;
    PanelDetalle.add(nombreJ, constraints);
    constraints.weightx = 0.0;

    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    PanelDetalle.add(apellidoL, constraints);

    constraints.gridx = 1;//Necesita estirarse
    constraints.gridy = 3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1.0;
    PanelDetalle.add(apellidoJ, constraints);
    constraints.weightx = 0.0;

    constraints.gridx = 0;
    constraints.gridy = 4;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    PanelDetalle.add(cedulaL, constraints);

    constraints.gridx = 1;//Necesita estirarse
    constraints.gridy = 4;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1.0;
    PanelDetalle.add(cedulaJ, constraints);
    constraints.weightx = 0.0;

    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    PanelDetalle.add(direccionL, constraints);

    constraints.gridx = 1;//Necesita estirarse
    constraints.gridy = 5;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1.0;
    PanelDetalle.add(direccionJ, constraints);
    constraints.weightx = 0.0;

    constraints.gridx = 0;
    constraints.gridy = 6;
    constraints.gridwidth = 1;
    constraints.gridheight = 2;
    constraints.weighty = 1.0;
    PanelDetalle.add(motivosL, constraints);

    constraints.gridx = 1;//Necesita estirarse
    constraints.gridy = 6;
    constraints.gridwidth = 1;
    constraints.gridheight = 2;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    PanelDetalle.add(motivosTA, constraints);
    constraints.weightx = 0.0;

    constraints.gridx = 0;
    constraints.gridy = 8;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    PanelDetalle.add(telefonoCasaL, constraints);

    constraints.gridx = 1;//Necesita estirarse
    constraints.gridy = 8;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1.0;
    PanelDetalle.add(telefonoCasaJ, constraints);
    constraints.weightx = 0.0;

    constraints.gridx = 0;
    constraints.gridy = 9;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    PanelDetalle.add(telefonoCelularL, constraints);

    constraints.gridx = 1;//Necesita estirarse
    constraints.gridy = 9;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1.0;
    PanelDetalle.add(telefonoCelularJ, constraints);
    constraints.weightx = 0.0;

    constraints.gridx = 0;
    constraints.gridy = 10;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    PanelDetalle.add(correoL, constraints);

    constraints.gridx = 1;//Necesita estirarse
    constraints.gridy = 10;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1.0;
    PanelDetalle.add(correoJ, constraints);
    constraints.weightx = 0.0;

    //PANEL DE LOS BOTONES

    constraints.insets.set(30, 0, 10, 10);

    constraints.gridx = 1;//Necesita estirarse
    constraints.gridy = 11;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.0;
    FlowLayout flowLayout1 = new FlowLayout();
    Botones.setLayout(flowLayout1);
    Botones.add(agregarB);
    Botones.add(modificarB);
    Botones.add(eliminarB);
    PanelDetalle.add(Botones, constraints);

    //Boton Buscar
    constraints.anchor = GridBagConstraints.NORTH;
    constraints.insets.set(10, 0, 0, 0);
    constraints.gridx = 2;//Necesita estirarse
    constraints.gridy = 4;
    constraints.gridwidth = 1;
    constraints.gridheight = 0;
    constraints.weightx = 0.0;
    BotonBuscar.setLayout(flowLayout1);
    BotonBuscar.add(buscarB);
    BotonBuscar.setBackground(colorBackGround);
    PanelDetalle.add(BotonBuscar, constraints);
    constraints.insets.set(30, 0, 10, 10);

    //BOTON ATRAS

    constraints.insets.set(30, 0, 10, 10);
    constraints.gridx = 2;//Necesita estirarse
    constraints.gridy = 11;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.0;

    BotonAtras.setLayout(flowLayout1);
    BotonAtras.add(atrasB);

    PanelDetalle.add(BotonAtras, constraints);

    cambiarColorPanel(Botones, colorDelPapa);
    cambiarColorPanel(BotonBuscar, colorDelPapa);
    cambiarColorPanel(BotonAtras, colorDelPapa);

    PanelDetalle.setVisible(true);

    //////////////////////ULTIMAS MOTIFICACIONES PRIMER INCREMENTO
    atrasB.setEnabled(false);
    buscarB.setEnabled(false);
    modificarB.setEnabled(false);
    agregarB.setEnabled(false);
    eliminarB.setEnabled(false);
    fechaJ.setEditable(false);
    horaJ.setEditable(false);
    nombreJ.setEditable(false);
    apellidoJ.setEditable(false);
    cedulaJ.setEditable(false);
    direccionJ.setEditable(false);
    motivosTA.setEditable(false);
    telefonoCasaJ.setEditable(false);
    telefonoCelularJ.setEditable(false);
    correoJ.setEditable(false);

    /////////////////////FIN ULTIMAS MOTIFICACIONES PRIMER INCREMENTO

    /////////////////Para enero

    setCitas();
    dibujarPanelCita(medico);//Dibuja la "libreta" de las citas

    /////// fin para ENERO

    //jCalendar1.getDayChooser().addDateEvaluator(new DJFechasEspInv());//Pinta las Fechas ocupadas en rojo
    jCalendar1.addPropertyChangeListener("calendar", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            try {
                try {
                    setCitas();
                } catch (ClientProtocolException ex) {
                    Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex);
                } catch (ParseException ex) {
                    Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex);
                } catch (java.text.ParseException ex) {
                    Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex);
                }
            } catch (IOException ex) {
                Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex);
            } catch (JSONException ex) {
                Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });

}

From source file:com.sec.ose.osi.ui.dialog.progress.JDlgProgress.java

/**
 * This method initializes jPanelContent   
 *    //from w  w  w.ja  v  a2  s .c  o m
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelContent() {
    if (jPanelContent == null) {
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.weighty = 1.0;
        gridBagConstraints1.insets = new Insets(35, 25, 0, 25);
        gridBagConstraints1.gridx = 0;

        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints2.weightx = 1.0;
        gridBagConstraints2.weighty = 1.0;
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.insets = new Insets(35, 25, 0, 25);
        gridBagConstraints2.gridy = 1;

        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.gridx = 0;
        gridBagConstraints3.insets = new Insets(20, 0, 20, 0);
        gridBagConstraints3.gridy = 2;

        jPanelContent = new JPanel();
        jPanelContent.setLayout(new GridBagLayout());
        jPanelContent.setPreferredSize(new Dimension(350, 150));
        jPanelContent.add(getJTextAreaMessage(), gridBagConstraints1);
        jPanelContent.add(getJButtonCancel(), gridBagConstraints3);
    }
    return jPanelContent;
}

From source file:net.mumie.coursecreator.gui.ClassChooser.java

private void buildLayout() {
    //       Dimensions of the Dialog      
    int width = 10;
    int height = 160;
    int buttonWidth = 100;
    int buttonHeight = 30;

    // sets the Layout
    this.getContentPane().setLayout(new GridBagLayout());

    // the Button and Label Text
    String okButtonText = "Zuweisen";
    String cancelButtonText = "Cancel";
    headlineLabelText = "";

    // the Fonts//from   w  ww  .  ja  v a 2s  .c  o m
    Font font = new Font("SansSerif", Font.PLAIN, 14);
    Font headlineLabelFont = new Font("SansSerif", Font.PLAIN, 12);
    Font textFieldFont = new Font("Monospaced", Font.PLAIN, 10);

    // GridBagContraints for rootPanel (s.b.):
    GridBagConstraints rootPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 0);

    // GridBagContraints for headlineLabel:
    GridBagConstraints headlineLabelStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 0, 0);

    // GridBagConstraints for textFieldPanel (s.b.):
    GridBagConstraints textFieldPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0,
            1);

    // GridBagConstraints for buttonPanel (s.b.):
    GridBagConstraints buttonPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 2);

    // GridBagConstraints for serverTextField:
    GridBagConstraints serverTextFieldStyle = createGridBagContrains(GridBagConstraints.WEST, 6, 6, 6, 6, 1, 0);

    // GridBagContraints for okButton (s.b.):
    GridBagConstraints okButtonStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 0, 0);

    // GridBagContraints for cancelButton (s.b.):
    GridBagConstraints cancelButtonStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 1, 0);

    // Creating rootPanel (contains all components)
    JPanel rootPanel = new JPanel(new GridBagLayout());
    rootPanel.setFont(font);

    // Creating headlineLabel:
    JLabel headlineLabel = new JLabel(headlineLabelText);
    headlineLabel.setFont(headlineLabelFont);

    // Creating textFieldPanel:
    JPanel textFieldPanel = new JPanel(new GridBagLayout());
    textFieldPanel.setFont(font);

    // Creating classTextField:
    classBox = new JComboBox(this.classList);
    classBox.setFont(textFieldFont);

    String classPath = this.controller.getMetaInfoField().getMetaInfos().getClassPath();
    String className = this.controller.getMetaInfoField().getMetaInfos().getClassName();

    if (setSelectedClass(classPath, className) == -1)
        headlineLabel.setForeground(Color.RED);
    else
        headlineLabel.setForeground(Color.BLACK);

    headlineLabel.setText(this.headlineLabelText);

    // Creating buttonPanel:
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    buttonPanel.setFont(font);

    // okButton:
    JButton okButton = new JButton(okButtonText);
    okButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight));
    okButton.setActionCommand(CommandConstants.META_INFO_FIELD_OK);
    okButton.addActionListener(this.controller);

    // cancelButton:
    JButton cancelButton = new JButton(cancelButtonText);
    cancelButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight));
    cancelButton.setActionCommand(CommandConstants.META_INFO_FIELD_CANCEL);
    cancelButton.addActionListener(this.controller);

    // Composing the GUI:
    this.getContentPane().setLayout(new GridBagLayout());
    this.getContentPane().add(rootPanel, rootPanelStyle);
    rootPanel.add(headlineLabel, headlineLabelStyle);
    rootPanel.add(textFieldPanel, textFieldPanelStyle);
    textFieldPanel.add(classBox, serverTextFieldStyle);
    rootPanel.add(buttonPanel, buttonPanelStyle);
    buttonPanel.add(okButton, okButtonStyle);
    buttonPanel.add(cancelButton, cancelButtonStyle);

    this.addWindowListener(this.windowListener);

    int maxString = this.headlineLabelText.length();
    for (int i = 0; i < this.classList.size(); i++) {
        maxString = Math.max(((String) this.classList.get(i).toString()).length(), maxString);
    }

    width = Math.max(width, maxString * 8);
    this.setSize(width, height);
}

From source file:org.bench4Q.console.ui.section.S_SummarizeSection.java

/**
 * @param resources// w  ww. ja va 2s  . c om
 * @param processControl
 * @param dispatcherFactory
 * @param TotalOrNot
 * @param agentIdentity
 * @param agentsCollection
 * @throws ConsoleException
 */
public S_SummarizeSection(Resources resources, ProcessControl processControl,
        SwingDispatcherFactory dispatcherFactory, Boolean TotalOrNot, AgentIdentity agentIdentity,
        AgentsCollection agentsCollection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_swingDispatcherFactory = dispatcherFactory;

    this.TotalOrNot = TotalOrNot;
    m_agentIdentity = agentIdentity;
    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    ErrorSession = new int[15];

    this.setLayout(new GridBagLayout());
    this.setPreferredSize(new Dimension(683, 475));
    this.setMinimumSize(new Dimension(683, 475));

    picPanel = new PicPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 5, 99.0, 99.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1));

}

From source file:marytts.tools.voiceimport.DatabaseImportMain.java

protected void setupGUI() {
    // A scroll pane containing one labelled checkbox per component,
    // and a "run selected components" button below.
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridC = new GridBagConstraints();
    getContentPane().setLayout(gridBagLayout);

    JPanel checkboxPane = new JPanel();
    checkboxPane.setLayout(new BoxLayout(checkboxPane, BoxLayout.Y_AXIS));
    //checkboxPane.setPreferredSize(new Dimension(300, 300));
    int compIndex = 0;
    for (int j = 0; j < groups2Comps.length; j++) {
        String[] nextGroup = groups2Comps[j];
        JPanel groupPane = new JPanel();
        groupPane.setLayout(new BoxLayout(groupPane, BoxLayout.Y_AXIS));
        groupPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(nextGroup[0]),
                BorderFactory.createEmptyBorder(1, 1, 1, 1)));
        for (int i = 1; i < nextGroup.length; i++) {
            JButton configButton = new JButton();
            Icon configIcon = new ImageIcon(DatabaseImportMain.class.getResource("configure.png"), "Configure");
            configButton.setIcon(configIcon);
            configButton.setPreferredSize(new Dimension(configIcon.getIconWidth(), configIcon.getIconHeight()));
            configButton.addActionListener(new ConfigButtonActionListener(nextGroup[i]));
            configButton.setBorderPainted(false);
            //System.out.println("Adding checkbox for "+components[i].getClass().getName());
            checkboxes[compIndex] = new JCheckBox(nextGroup[i]);
            checkboxes[compIndex].setFocusable(true);
            //checkboxes[i].setPreferredSize(new Dimension(200, 30));
            JPanel line = new JPanel();
            line.setLayout(new BorderLayout(5, 0));
            line.add(configButton, BorderLayout.WEST);
            line.add(checkboxes[compIndex], BorderLayout.CENTER);
            groupPane.add(line);//w  ww.  j ava2 s  . c o m
            compIndex++;
        }
        checkboxPane.add(groupPane);
    }
    gridC.gridx = 0;
    gridC.gridy = 0;
    gridC.fill = GridBagConstraints.BOTH;
    JScrollPane scrollPane = new JScrollPane(checkboxPane);
    scrollPane.setPreferredSize(new Dimension(450, 300));
    gridBagLayout.setConstraints(scrollPane, gridC);
    getContentPane().add(scrollPane);

    JButton helpButton = new JButton("Help");
    helpButton.setMnemonic(KeyEvent.VK_H);
    helpButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            displayHelpGUI();
        }
    });
    JButton settingsButton = new JButton("Settings");
    settingsButton.setMnemonic(KeyEvent.VK_S);
    settingsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            currentComponent = "Global properties";
            displaySettingsGUI();
        }
    });
    runButton = new JButton("Run");
    runButton.setMnemonic(KeyEvent.VK_R);
    runButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            runSelectedComponents();
        }
    });

    JButton quitAndSaveButton = new JButton("Quit");
    quitAndSaveButton.setMnemonic(KeyEvent.VK_Q);
    quitAndSaveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                askIfSave();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            System.exit(0);
        }
    });

    gridC.gridy = 1;
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());
    //buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS));
    //runButton.setAlignmentX(JButton.LEFT_ALIGNMENT);
    buttonPanel.add(runButton);
    //helpButton.setAlignmentX(JButton.LEFT_ALIGNMENT);
    buttonPanel.add(helpButton);
    //settingsButton.setAlignmentX(JButton.LEFT_ALIGNMENT);
    buttonPanel.add(settingsButton);
    //buttonPanel.add(Box.createHorizontalGlue());
    //quitAndSaveButton.setAlignmentX(JButton.RIGHT_ALIGNMENT);
    buttonPanel.add(quitAndSaveButton);
    gridBagLayout.setConstraints(buttonPanel, gridC);
    getContentPane().add(buttonPanel);

    //getContentPane().setPreferredSize(new Dimension(300, 300));
    // End program when closing window:
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            try {
                askIfSave();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            System.exit(0);
        }
    });
}

From source file:com.intel.stl.ui.monitor.view.PSEventsPieChart.java

protected JPanel getLengendPanel() {
    JPanel panel = new JPanel();
    panel.setOpaque(false);/*from   w ww.j  a  v a2s  .  com*/
    panel.setLayout(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();

    gc.fill = GridBagConstraints.BOTH;
    StateLongTypeViz[] states = StateLongTypeViz.values();
    stateLabels = new JLabel[states.length];
    for (int i = 0; i < states.length; i++) {
        StateLongTypeViz state = states[i];
        gc.insets = new Insets(2, 5, 2, 2);
        gc.weightx = 0;
        gc.gridwidth = 1;

        JLabel label = new JLabel(state.getName(),
                Util.generateImageIcon(state.getColor(), 8, new Insets(1, 1, 1, 1)), JLabel.LEFT);
        label.setFont(UIConstants.H5_FONT);
        label.setForeground(UIConstants.INTEL_DARK_GRAY);
        panel.add(label, gc);

        gc.gridwidth = GridBagConstraints.REMAINDER;
        gc.weightx = 0;
        stateLabels[i] = new JLabel();
        stateLabels[i].setForeground(UIConstants.INTEL_DARK_GRAY);
        stateLabels[i].setFont(UIConstants.H5_FONT);
        panel.add(stateLabels[i], gc);
    }
    return panel;
}

From source file:de.codesourcery.jasm16.ide.ui.views.ProjectConfigurationView.java

@Override
protected JPanel getPanel() {
    final JPanel result = new JPanel();
    result.setLayout(new GridBagLayout());

    // project name
    int y = 0;/*from   w w  w  . j  a v a  2 s. c  o m*/
    GridBagConstraints cnstrs = constraints(0, y, false, false, GridBagConstraints.NONE);
    result.add(new JLabel("Project name"), cnstrs);

    cnstrs = constraints(1, y++, true, false, GridBagConstraints.NONE);
    result.add(projectName, cnstrs);

    // build options panel
    final JPanel buildOptionsPanel = new JPanel();
    buildOptionsPanel.setLayout(new GridBagLayout());

    buildOptionsPanel.setBorder(BorderFactory.createTitledBorder("Build options"));

    cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE);
    buildOptionsPanel.add(new JLabel("Compilation root"), cnstrs);

    cnstrs = constraints(1, 0, false, false, GridBagConstraints.NONE);
    compilationRootName.setEditable(false);
    compilationRootName.setColumns(25);
    buildOptionsPanel.add(compilationRootName, cnstrs);

    cnstrs = constraints(2, 0, true, false, GridBagConstraints.NONE);
    buildOptionsPanel.add(compilationRootButton, cnstrs);

    compilationRootButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser chooser;
            File baseDir = null;
            if (project != null) {
                baseDir = project.getConfiguration().getBaseDirectory();
            }
            if (StringUtils.isNotBlank(compilationRootName.getText())) {
                File tmp = new File(compilationRootName.getText()).getParentFile();
                if (tmp.exists() && tmp.isDirectory()) {
                    baseDir = tmp;
                }
            }
            if (baseDir != null) {
                chooser = new JFileChooser(baseDir);
            } else {
                chooser = new JFileChooser();
            }
            final int result = chooser.showOpenDialog(null);
            if (result == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile().isFile()) {
                compilationRootName.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });

    // generate self-relocating code ?
    cnstrs = constraints(0, 1, false, false, GridBagConstraints.NONE);
    buildOptionsPanel.add(new JLabel("Generate self-relocating code?"), cnstrs);

    cnstrs = constraints(1, 1, true, true, GridBagConstraints.NONE);
    cnstrs.gridwidth = 2;
    buildOptionsPanel.add(generateSelfRelocatingCode, cnstrs);

    // inline short literals ?
    cnstrs = constraints(0, 2, false, false, GridBagConstraints.NONE);
    buildOptionsPanel.add(new JLabel("Inline short literals?"), cnstrs);

    cnstrs = constraints(1, 2, true, true, GridBagConstraints.NONE);
    cnstrs.gridwidth = 2;
    buildOptionsPanel.add(inlineShortLiterals, cnstrs);

    // add build options panel to parent
    cnstrs = constraints(0, y++, true, false, GridBagConstraints.BOTH);
    cnstrs.gridwidth = 2;
    result.add(buildOptionsPanel, cnstrs);

    // buttons
    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());

    cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE);
    buttonPanel.add(saveButton, cnstrs);
    saveButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (hasValidInput()) {
                onSave();
            }
        }
    });

    cnstrs = constraints(1, 0, true, true, GridBagConstraints.NONE);
    buttonPanel.add(cancelButton, cnstrs);
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            onCancel();
        }
    });

    // button panel
    cnstrs = constraints(0, y++, true, true, GridBagConstraints.NONE);
    cnstrs.gridwidth = 2;
    result.add(buttonPanel, cnstrs);

    return result;
}