Example usage for java.awt Container setLayout

List of usage examples for java.awt Container setLayout

Introduction

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

Prototype

public void setLayout(LayoutManager mgr) 

Source Link

Document

Sets the layout manager for this container.

Usage

From source file:fungus.JungVisualizer.java

public JungVisualizer(String name) {
    this.name = name;

    showEdges = Configuration.getBoolean(name + "." + PAR_SHOW_EDGES);
    scaleShapes = Configuration.getBoolean(name + "." + PAR_SCALE_SHAPES);
    labelNodes = Configuration.getBoolean(name + "." + PAR_LABEL_NODES);
    imageDir = Configuration.getString(name + "." + PAR_IMAGE_DIR);
    nameFragment = Configuration.getString(PAR_TESTNAME);

    if (vt == null) {
        try {/*from  w ww .  j a  v  a2  s . c  o m*/
            Class vtClass = Configuration.getClass(name + "." + PAR_TRANSFORMERS);
            if (VisualizerTransformers.class.isAssignableFrom(vtClass)) {
                vt = (VisualizerTransformers) vtClass.newInstance();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    graph = JungGraphObserver.getGraph();

    vt.setGraph(graph); // Have to call this manually!

    JungGraphObserver.stepBlocked = true;
    JungGraphObserver.noBlock = false;

    layout = vt.makeLayout(graph);

    Dimension preferredSize = new Dimension(660, 660);
    visualizationModel = new DefaultVisualizationModel<MycoNode, MycoEdge>(layout, preferredSize);

    relaxer = visualizationModel.getRelaxer();

    visualizer = new VisualizationViewer<MycoNode, MycoEdge>(visualizationModel, preferredSize);
    visualizer.addGraphMouseListener(new InfoFrameVertexListener());

    visualizer.setDoubleBuffered(true);

    // final Color under50VertexColor = Color.BLACK;
    // final Stroke under50VertexStroke = new BasicStroke(1.0f,
    //                                                    BasicStroke.CAP_BUTT,
    //                                                    BasicStroke.JOIN_MITER);
    // final Color over50VertexColor = Color.MAGENTA;
    // final Stroke over50VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over80VertexColor = Color.BLUE;
    // final Stroke over80VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over95VertexColor = Color.GREEN;
    // final Stroke over95VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over100VertexColor = Color.RED;
    // final Stroke over100VertexStroke = new BasicStroke(5.0f,
    //                                                    BasicStroke.CAP_BUTT,
    //                                                    BasicStroke.JOIN_MITER);
    // Transformer<MycoNode,Stroke> nodeStrokeRenderer =
    //     new Transformer<MycoNode, Stroke>() {
    //   public Stroke transform(MycoNode n){
    //     int capacity = n.getHyphaData().getMax();
    //     int attached = n.getHyphaLink().degree();
    //     double ratio = ((double) attached) / ((double) capacity);

    //     if (ratio > 1.0) {
    //       return over100VertexStroke;
    //     } else if (ratio > 0.95) {
    //       return over95VertexStroke;
    //     } else if (ratio > 0.80) {
    //       return over80VertexStroke;
    //     } else if (ratio > 0.50) {
    //       return over50VertexStroke;
    //     } else {
    //       return under50VertexStroke;
    //     }
    //   }
    // };
    // Transformer<MycoNode,Paint> nodeOutlineRenderer =
    //     new Transformer<MycoNode, Paint>() {
    //   public Paint transform(MycoNode n) {
    //     int capacity = n.getHyphaData().getMax();
    //     int attached = n.getHyphaLink().degree();
    //     double ratio = ((double) attached) / ((double) capacity);

    //     if (ratio > 1.0) {
    //       return over100VertexColor;
    //     } else if (ratio > 0.95) {
    //       return over95VertexColor;
    //     } else if (ratio > 0.80) {
    //       return over80VertexColor;
    //     } else if (ratio > 0.50) {
    //       return over50VertexColor;
    //     } else {
    //       return under50VertexColor;
    //     }
    //   }
    // };

    /*Transformer<MycoNode,Paint> nodeFillRenderer = new Transformer<MycoNode,Paint>() {
      public Paint transform(MycoNode n) {
      HyphaData data = n.getHyphaData();
      if (!n.isUp()) { return Color.BLACK; }
      if (data.isBiomass()) { return Color.BLUE; }
      else if (data.isExtending()) { return Color.RED; }
      else if (data.isBranching()) { return Color.YELLOW; }
      else { return Color.GREEN; }
      }
      };*/

    /*Transformer<MycoNode,Paint> nodeFillRenderer = new Transformer<MycoNode,Paint>() {
      public Paint transform(MycoNode n) {
      HyphaData data = n.getHyphaData();
      if (data.isBiomass()) { return Color.BLUE; }
      else if (data.isExtending()) { return Color.RED; }
      else if (data.isBranching()) { return Color.YELLOW; }
      else { return Color.GREEN; }
      }
      };*/

    final Color transparent = new Color(0, 0, 0, 0);

    Transformer<MycoEdge, Paint> transparentEdges = new Transformer<MycoEdge, Paint>() {
        public Paint transform(MycoEdge e) {
            return transparent;
        }
    };

    visualizer.setBackground(Color.WHITE);

    visualizer.getRenderContext().setVertexFillPaintTransformer(vt.getNodeFillRenderer());
    visualizer.getRenderContext().setVertexShapeTransformer(vt.getShapeTransformer(scaleShapes));
    if (labelNodes) {
        visualizer.getRenderContext().setVertexLabelTransformer(vt.getNodeLabeller());
    }
    visualizer.getRenderContext().setVertexStrokeTransformer(vt.getVertexStrokeTransformer());
    visualizer.getRenderContext().setVertexDrawPaintTransformer(vt.getVertexDrawPaintTransformer());
    //visualizer.setVertexToolTipTransformer(new ToStringLabeller());

    if (showEdges) {
        visualizer.getRenderContext().setEdgeStrokeTransformer(vt.getEdgeStrokeTransformer());
        visualizer.getRenderContext().setEdgeDrawPaintTransformer(vt.getEdgeDrawPaintTransformer());
        visualizer.getRenderContext().setArrowDrawPaintTransformer(vt.getEdgeDrawPaintTransformer());
        visualizer.getRenderContext().setArrowFillPaintTransformer(vt.getEdgeDrawPaintTransformer());
    } else {
        visualizer.getRenderContext().setEdgeDrawPaintTransformer(transparentEdges);
        visualizer.getRenderContext().setArrowDrawPaintTransformer(transparentEdges);
        visualizer.getRenderContext().setArrowFillPaintTransformer(transparentEdges);
    }

    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container c = frame.getContentPane();
    c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));

    //JScrollPane scrollPane = new JScrollPane(visualizer);
    //c.add(scrollPane);
    c.add(visualizer);

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));

    final JButton captureButton = new JButton("capture");
    ActionListener capturer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            saveAsPNG();
        }
    };
    captureButton.addActionListener(capturer);

    final JButton freezeButton = new JButton("freeze");
    ActionListener freezer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (freezeButton.getText().equals("freeze")) {
                relaxer.pause();
                freezeButton.setText("unfreeze");
            } else {
                relaxer.resume();
                freezeButton.setText("freeze");
            }
        }
    };
    freezeButton.addActionListener(freezer);

    JButton pauseButton = new JButton("pause");
    ActionListener pauser = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //e.consume();
            JungGraphObserver.pauseAction();
        }
    };
    pauseButton.addActionListener(pauser);

    JButton stepButton = new JButton("step");
    ActionListener stepper = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked!\n");
            //e.consume();
            JungGraphObserver.stepAction();
        }
    };
    stepButton.addActionListener(stepper);

    JButton walkButton = new JButton("walk");
    ActionListener walker = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked!\n");
            //e.consume();
            JungGraphObserver.walkAction();
        }
    };
    walkButton.addActionListener(walker);

    JButton runButton = new JButton("run");
    ActionListener runner = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //e.consume();
            JungGraphObserver.runAction();
        }
    };
    runButton.addActionListener(runner);

    roundField = new JTextField("0");

    buttonPane.add(freezeButton);
    buttonPane.add(captureButton);
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(pauseButton);
    buttonPane.add(stepButton);
    buttonPane.add(walkButton);
    buttonPane.add(runButton);
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(roundField);
    c.add(buttonPane);

    frame.pack();
    frame.setVisible(true);

    JungGraphObserver.setVisualizer(visualizer);
}

From source file:op.care.med.inventory.DlgCloseStock.java

/**
 * This method is called from within the constructor to
 * initialize the form.//from   w ww  . ja v  a  2  s.  c  o m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jPanel1 = new JPanel();
    jScrollPane1 = new JScrollPane();
    txtInfo = new JTextPane();
    rbLeer = new JRadioButton();
    rbStellen = new JRadioButton();
    txtLetzte = new JTextField();
    lblEinheiten = new JLabel();
    rbAbgelaufen = new JRadioButton();
    jSeparator1 = new JSeparator();
    jLabel2 = new JLabel();
    jLabel3 = new JLabel();
    rbGefallen = new JRadioButton();
    cmbBestID = new JComboBox();
    panel1 = new JPanel();
    btnClose = new JButton();
    btnOk = new JButton();

    //======== this ========
    setResizable(false);
    setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));

    //======== jPanel1 ========
    {
        jPanel1.setBorder(null);
        jPanel1.setLayout(new FormLayout("14dlu, $lcgap, 145dlu, $lcgap, 41dlu, $lcgap, 93dlu, $lcgap, 14dlu",
                "14dlu, $lgap, fill:70dlu:grow, 4*($lgap, fill:default), $lgap, $rgap, $lgap, fill:default, $lgap, $rgap, $lgap, default, $lgap, 14dlu"));

        //======== jScrollPane1 ========
        {

            //---- txtInfo ----
            txtInfo.setEditable(false);
            txtInfo.setFont(new Font("Arial", Font.PLAIN, 14));
            jScrollPane1.setViewportView(txtInfo);
        }
        jPanel1.add(jScrollPane1, CC.xywh(3, 3, 5, 1));

        //---- rbLeer ----
        rbLeer.setSelected(true);
        rbLeer.setText("Die Packung ist nun leer");
        rbLeer.setFont(new Font("Arial", Font.PLAIN, 14));
        rbLeer.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rbLeerActionPerformed(e);
            }
        });
        jPanel1.add(rbLeer, CC.xy(3, 5));

        //---- rbStellen ----
        rbStellen.setText("Beim Vorab Stellen haben Sie die letzten ");
        rbStellen.setFont(new Font("Arial", Font.PLAIN, 14));
        rbStellen.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rbStellenActionPerformed(e);
            }
        });
        jPanel1.add(rbStellen, CC.xywh(3, 7, 2, 1));

        //---- txtLetzte ----
        txtLetzte.setText("jTextField1");
        txtLetzte.setFont(new Font("Arial", Font.PLAIN, 14));
        txtLetzte.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                txtLetzteFocusLost(e);
            }
        });
        jPanel1.add(txtLetzte, CC.xy(5, 7));

        //---- lblEinheiten ----
        lblEinheiten.setText("Einheiten verbraucht.");
        lblEinheiten.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(lblEinheiten, CC.xy(7, 7));

        //---- rbAbgelaufen ----
        rbAbgelaufen.setText(
                "Die Packung ist abgelaufen oder wird nicht mehr ben\u00f6tigt. Bereit zur Entsorgung.");
        rbAbgelaufen.setFont(new Font("Arial", Font.PLAIN, 14));
        rbAbgelaufen.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rbAbgelaufenActionPerformed(e);
            }
        });
        jPanel1.add(rbAbgelaufen, CC.xywh(3, 9, 5, 1));
        jPanel1.add(jSeparator1, CC.xywh(3, 13, 5, 1));

        //---- jLabel2 ----
        jLabel2.setText("Als n\u00e4chstes Packung soll die Nummer");
        jLabel2.setFont(new Font("Arial", Font.PLAIN, 14));
        jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
        jPanel1.add(jLabel2, CC.xy(3, 15));

        //---- jLabel3 ----
        jLabel3.setText("angebrochen werden.");
        jLabel3.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(jLabel3, CC.xy(7, 15));

        //---- rbGefallen ----
        rbGefallen.setText(
                "<html>Die Packung ist <font color=\"red\">runter gefallen</font> oder <font color=\"red\">verschwunden</font> und muss ausgebucht werden.</html>");
        rbGefallen.setFont(new Font("Arial", Font.PLAIN, 14));
        rbGefallen.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rbGefallenActionPerformed(e);
            }
        });
        jPanel1.add(rbGefallen, CC.xywh(3, 11, 5, 1));

        //---- cmbBestID ----
        cmbBestID.setModel(new DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbBestID.setFont(new Font("Arial", Font.PLAIN, 14));
        cmbBestID.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                cmbBestIDItemStateChanged(e);
            }
        });
        jPanel1.add(cmbBestID, CC.xy(5, 15));

        //======== panel1 ========
        {
            panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));

            //---- btnClose ----
            btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
            btnClose.setText(null);
            btnClose.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnCloseActionPerformed(e);
                }
            });
            panel1.add(btnClose);

            //---- btnOk ----
            btnOk.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
            btnOk.setText(null);
            btnOk.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnOkActionPerformed(e);
                }
            });
            panel1.add(btnOk);
        }
        jPanel1.add(panel1, CC.xy(7, 19, CC.RIGHT, CC.DEFAULT));
    }
    contentPane.add(jPanel1);
    pack();
    setLocationRelativeTo(getOwner());

    //---- buttonGroup1 ----
    ButtonGroup buttonGroup1 = new ButtonGroup();
    buttonGroup1.add(rbLeer);
    buttonGroup1.add(rbStellen);
    buttonGroup1.add(rbAbgelaufen);
    buttonGroup1.add(rbGefallen);
}

From source file:op.care.info.DlgDiag.java

/**
 * This method is called from within the constructor to
 * initialize the form./* w  w  w. j a  va 2  s.  c om*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jPanel1 = new JPanel();
    txtSuche = new JXSearchField();
    lblTX = new JLabel();
    jspDiagnosen = new JScrollPane();
    lstDiag = new JList();
    lblDiagBy = new JLabel();
    cmbArzt = new JComboBox<>();
    btnAddGP = new JButton();
    cmbKH = new JComboBox<>();
    btnAddHospital = new JButton();
    lblSecurity = new JLabel();
    lblSide = new JLabel();
    cmbKoerper = new JComboBox<>();
    cmbSicherheit = new JComboBox<>();
    jScrollPane1 = new JScrollPane();
    txtBemerkung = new JTextArea();
    lblInterval = new JLabel();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnOK = new JButton();

    //======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== jPanel1 ========
    {
        jPanel1.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED));
        jPanel1.setLayout(new FormLayout(
                "default, $lcgap, pref, $lcgap, default:grow, $ugap, pref, $lcgap, default:grow, 2*($lcgap, default)",
                "default, $lgap, fill:default, $lgap, fill:104dlu:grow, $lgap, fill:default, $lgap, default, $lgap, fill:default, $lgap, fill:89dlu:grow, $ugap, default, $lgap, default"));

        //---- txtSuche ----
        txtSuche.setFont(new Font("Arial", Font.PLAIN, 14));
        txtSuche.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                txtSucheActionPerformed(e);
            }
        });
        jPanel1.add(txtSuche, CC.xywh(3, 3, 7, 1));

        //---- lblTX ----
        lblTX.setText(null);
        lblTX.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/ambulance2.png")));
        jPanel1.add(lblTX, CC.xy(11, 3));

        //======== jspDiagnosen ========
        {

            //---- lstDiag ----
            lstDiag.setFont(new Font("Arial", Font.PLAIN, 14));
            jspDiagnosen.setViewportView(lstDiag);
        }
        jPanel1.add(jspDiagnosen, CC.xywh(3, 5, 9, 1));

        //---- lblDiagBy ----
        lblDiagBy.setText("Festgestellt durch:");
        lblDiagBy.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(lblDiagBy, CC.xy(3, 7, CC.RIGHT, CC.DEFAULT));

        //---- cmbArzt ----
        cmbArzt.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbArzt.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbArzt, CC.xywh(5, 7, 5, 1));

        //---- btnAddGP ----
        btnAddGP.setText(null);
        btnAddGP.setBorder(null);
        btnAddGP.setContentAreaFilled(false);
        btnAddGP.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
        btnAddGP.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnAddGP.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
        btnAddGP.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnAddGPActionPerformed(e);
            }
        });
        jPanel1.add(btnAddGP, CC.xy(11, 7));

        //---- cmbKH ----
        cmbKH.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbKH.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbKH, CC.xywh(5, 9, 5, 1));

        //---- btnAddHospital ----
        btnAddHospital.setText(null);
        btnAddHospital.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
        btnAddHospital.setBorder(null);
        btnAddHospital.setContentAreaFilled(false);
        btnAddHospital.setBorderPainted(false);
        btnAddHospital.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnAddHospital.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
        btnAddHospital.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnAddHospitalActionPerformed(e);
            }
        });
        jPanel1.add(btnAddHospital, CC.xy(11, 9));

        //---- lblSecurity ----
        lblSecurity.setText("Diagnosesicherheit:");
        lblSecurity.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(lblSecurity, CC.xy(7, 11));

        //---- lblSide ----
        lblSide.setText("K\u00f6rperseite:");
        lblSide.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(lblSide, CC.xy(3, 11, CC.RIGHT, CC.DEFAULT));

        //---- cmbKoerper ----
        cmbKoerper.setModel(new DefaultComboBoxModel<>(
                new String[] { "Nicht festgelegt", "links", "rechts", "beidseitig" }));
        cmbKoerper.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbKoerper, CC.xy(5, 11));

        //---- cmbSicherheit ----
        cmbSicherheit.setModel(new DefaultComboBoxModel<>(new String[] { "Nicht festgelegt", "gesichert",
                "Verdacht auf", "Ausschlu\u00df von", "Zustand nach" }));
        cmbSicherheit.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbSicherheit, CC.xywh(9, 11, 3, 1));

        //======== jScrollPane1 ========
        {

            //---- txtBemerkung ----
            txtBemerkung.setColumns(20);
            txtBemerkung.setRows(5);
            txtBemerkung.setFont(new Font("Arial", Font.PLAIN, 14));
            jScrollPane1.setViewportView(txtBemerkung);
        }
        jPanel1.add(jScrollPane1, CC.xywh(3, 13, 9, 1));

        //---- lblInterval ----
        lblInterval.setText("text");
        jPanel1.add(lblInterval, CC.xywh(3, 15, 5, 1));

        //======== panel1 ========
        {
            panel1.setLayout(new HorizontalLayout(5));

            //---- btnCancel ----
            btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
            btnCancel.setText(null);
            btnCancel.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnCancelActionPerformed(e);
                }
            });
            panel1.add(btnCancel);

            //---- btnOK ----
            btnOK.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
            btnOK.setText(null);
            btnOK.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnOKActionPerformed(e);
                }
            });
            panel1.add(btnOK);
        }
        jPanel1.add(panel1, CC.xywh(7, 15, 5, 1, CC.RIGHT, CC.DEFAULT));
    }
    contentPane.add(jPanel1, BorderLayout.CENTER);
    setSize(730, 565);
    setLocationRelativeTo(getOwner());
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.preenchedor_formulario.PanelPreenchedorFormulario.java

private void criaInterfaceVisualEscalavel() {
    miBtnSalvar = new JMenuItem(XHTML_Panel.BTN_SALVAR);
    painel = new JPanel();
    textAreaSourceCode = new G_TextAreaSourceCode();
    // frameSilvinha.setJMenuBar(this.criaMenuBar());
    new OnChange(textAreaSourceCode, this);

    textAreaSourceCode.setTipoHTML();/*www.  ja va 2  s . c  om*/
    textAreaSourceCode.setBorder(criaBorda(XHTML_Panel.COD_FONTE));

    painel.setLayout(new GridLayout(2, 1));
    setBackground(frameSilvinha.corDefault);

    Container contentPane = this;
    contentPane.setLayout(new GridLayout(1, 1));
    painel.add(textAreaSourceCode);

    JPanel panelBtnTabela = new JPanel();

    panelBtnTabela.setLayout(new BorderLayout());

    /*
     * Barra de botes
     */
    btnPanel = new JPanel();
    btnPanel.setLayout(null);
    btn_salvar = new JButton(XHTML_Panel.BTN_SALVAR);
    btn_salvar.setToolTipText(XHTML_Panel.DICA_SALVAR);
    btn_salvar.setBounds(10, 0, 150, 25);
    btnPanel.add(btn_salvar);

    btn_abrir = new JButton(XHTML_Panel.BTN_ABRIR);
    btn_abrir.setToolTipText(XHTML_Panel.DICA_ABRIR);
    btn_abrir.setBounds(165, 0, 150, 25);
    btnPanel.add(btn_abrir);

    btn_salvarComo = new JButton(XHTML_Panel.BTN_SALVAR_COMO);
    btn_salvarComo.setToolTipText(XHTML_Panel.DICA_SALVAR_COMO);
    btn_salvarComo.setBounds(320, 0, 150, 25);
    btnPanel.add(btn_salvarComo);

    btn_cancelar = new JButton(XHTML_Panel.TELA_ANTERIOR);
    btn_cancelar.setToolTipText(XHTML_Panel.DICA_TELA_ANTERIOR);
    btn_cancelar.setBounds(480, 0, 150, 25);
    btnPanel.add(btn_cancelar);

    btnPanel.setPreferredSize(new Dimension(430, 30));

    /*
     * Barra de correcao
     */
    btnAplicar = new JButton(XHTML_Panel.BTN_APLICAR);
    btnAplicar.setToolTipText(XHTML_Panel.DICA_BTN_APLICAR);
    btnAplicar.setEnabled(false);

    texto = new JTextField();

    texto.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    JPanel borda = new JPanel(new BorderLayout());
    JLabel lbl_texto = new JLabel(XHTML_Panel.ROTULO_TEXTO);
    lbl_texto.setToolTipText(XHTML_Panel.DICA_ROTULO_TEXTO);
    borda.add(lbl_texto, BorderLayout.WEST);
    borda.add(texto, BorderLayout.CENTER);
    borda.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    borda.setOpaque(false);
    panelCorretor = new JPanel(new BorderLayout());
    panelCorretor.add(borda, BorderLayout.CENTER);
    panelCorretor.add(btnAplicar, BorderLayout.EAST);
    //panelCorretor.add(btnPanel, BorderLayout.WEST);
    panelCorretor.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
    panelCorretor.setOpaque(false);

    /*
     * Tabela de erros
     */
    tabelaDeErros = new TabelaErros();
    scrollPaneTabela = new JScrollPane();
    scrollPaneTabela.setViewportView(tabelaDeErros);
    panelBtnTabela.add(panelCorretor, BorderLayout.NORTH);
    panelBtnTabela.add(scrollPaneTabela, BorderLayout.CENTER);
    panelBtnTabela.add(btnPanel, BorderLayout.SOUTH);
    scrollPaneTabela.setBorder(criaBorda(XHTML_Panel.LISTA_ERROS));
    painel.add(panelBtnTabela);

    btnPanel.setBackground(frameSilvinha.corDefault);

    if (!original) {
        reverter = new JButton("Reverter");
        reverter.setText(TradPainelRelatorio.REVERTER);
        reverter.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                setVisible(false);
                TxtBuffer.setContent(TxtBuffer.getContentOriginal());
                frameSilvinha.showPainelPreencheCampo();
                setVisible(true);
            }
        });
        //reverter.setActionCommand("Reverter");
        reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER);
        reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER);
        reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER);
        reverter.setBounds(640, 0, 150, 25);
        btnPanel.add(reverter);
    }

    panelBtnTabela.setBackground(frameSilvinha.corDefault);
    painel.setBackground(frameSilvinha.corDefault);
    contentPane.setBackground(frameSilvinha.corDefault);
    scrollPaneTabela.setBackground(frameSilvinha.corDefault);
    textAreaSourceCode.setBackground(frameSilvinha.corDefault);
    miBtnSalvar.setEnabled(false);
    btn_salvar.setEnabled(false);
    salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(textAreaSourceCode.getTextPane(), btn_salvar,
            miBtnSalvar, frameSilvinha);
    contentPane.add(painel);
    // pack();
    this.setVisible(true);
}

From source file:pcgen.gui2.dialog.ExportDialog.java

private void initLayout() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    Box topPanel = Box.createHorizontalBox();
    topPanel.add(new JLabel("Select Character:"));
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(characterBox);/* ww  w  . j a  v a  2 s  .  c o  m*/
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(partyBox);
    topPanel.add(Box.createHorizontalGlue());
    topPanel.add(Box.createHorizontalStrut(50));
    topPanel.add(new JLabel("Export to:"));
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(exportBox);
    contentPane.add(topPanel, BorderLayout.NORTH);

    JScrollPane scrollPane = new JScrollPane(fileList);
    scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Templates"),
            scrollPane.getBorder()));
    contentPane.add(scrollPane, BorderLayout.CENTER);

    Box bottomPanel = Box.createHorizontalBox();
    bottomPanel.add(progressBar);
    bottomPanel.add(Box.createHorizontalGlue());
    bottomPanel.add(Box.createHorizontalStrut(5));
    bottomPanel.add(exportButton);
    bottomPanel.add(Box.createHorizontalStrut(5));
    bottomPanel.add(closeButton);
    contentPane.add(bottomPanel, BorderLayout.SOUTH);

    topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bottomPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    pack();
}

From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java

private JDialog createAddChildDialog() {
    final JDialog dlg = new JDialog();
    dlg.setModal(true);/*from  w  w w. ja v a 2s.c o  m*/

    // Content
    final JPanel content = new JPanel();
    content.setLayout(new BorderLayout());
    content.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // child name
    AlignmentGridPanel pathPanel = new AlignmentGridPanel();

    final JTextField childNameText = new JTextField();
    final RSyntaxTextArea childDataArea = new RSyntaxTextArea();

    final JMenuBar bar = new JMenuBar();
    final JMenu menu = new JMenu("Syntax Highlight");
    bar.add(menu);

    setMenuItem(menu, childDataArea, SyntaxConstants.SYNTAX_STYLE_XML);
    setMenuItem(menu, childDataArea, SyntaxConstants.SYNTAX_STYLE_JAVA);
    setMenuItem(menu, childDataArea, SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE);

    pathPanel.addLine(new Component[] { new JLabel("Select:"), bar });
    pathPanel.addLine(new Component[] { new JLabel("Name: "), childNameText });
    pathPanel.addLine(new Component[] { new JLabel("Data: ") });

    content.add(pathPanel, BorderLayout.NORTH);
    content.add(new RTextScrollPane(childDataArea), BorderLayout.CENTER);

    childDataArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE);
    // Buttons.
    final CButtonPane btnPanel = new CButtonPane(CButtonPane.TAIL);
    final JButton btnOk = new JButton("Ok");
    btnOk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String name = childNameText.getText();
            String data = childDataArea.getText();

            if ((name == null || name.isEmpty()) || (data == null || data.isEmpty())) {
                JOptionPane.showMessageDialog(null, "Name or Data is empty", "Error",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            childName = name;
            childText = data;
            dlg.setVisible(false);
            dlg.dispose();
        }
    });

    final JButton btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            childName = "";
            childText = "";
            dlg.setVisible(false);
            dlg.dispose();
        }
    });
    btnPanel.add(btnCancel);
    btnPanel.add(btnOk);
    btnPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    Container con = dlg.getContentPane();
    con.setLayout(new BorderLayout());

    con.add(content, BorderLayout.CENTER);
    con.add(btnPanel, BorderLayout.SOUTH);

    return dlg;
}

From source file:misc.ModalityDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method is invoked from the/*from   ww w . ja  v a 2s. co  m*/
 * event-dispatching thread.
 */
private void createAndShowGUI() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    Insets ins = Toolkit.getDefaultToolkit().getScreenInsets(gc);
    int sw = gc.getBounds().width - ins.left - ins.right;
    int sh = gc.getBounds().height - ins.top - ins.bottom;

    // first document

    // frame f1

    f1 = new JFrame("Book 1 (parent frame)");
    f1.setBounds(32, 32, 300, 200);
    f1.addWindowListener(closeWindow);
    // create radio buttons
    rb11 = new JRadioButton("Biography", true);
    rb12 = new JRadioButton("Funny tale", false);
    rb13 = new JRadioButton("Sonnets", false);
    // place radio buttons into a single group
    ButtonGroup bg1 = new ButtonGroup();
    bg1.add(rb11);
    bg1.add(rb12);
    bg1.add(rb13);
    JButton b1 = new JButton("OK");
    b1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // get label of selected radiobutton
            String title = null;
            if (rb11.isSelected()) {
                title = rb11.getText();
            } else if (rb12.isSelected()) {
                title = rb12.getText();
            } else {
                title = rb13.getText();
            }
            // prepend radio button label to dialogs' titles
            d2.setTitle(title + " (modeless dialog)");
            d3.setTitle(title + " (document-modal dialog)");
            d2.setVisible(true);
        }
    });
    Container cp1 = f1.getContentPane();
    // create three containers to improve layouting
    cp1.setLayout(new GridLayout(1, 3));
    // an empty container
    Container cp11 = new Container();
    // a container to layout components
    Container cp12 = new Container();
    // an empty container
    Container cp13 = new Container();
    // add a button into a separate panel
    JPanel p1 = new JPanel();
    p1.setLayout(new FlowLayout());
    p1.add(b1);
    // add radio buttons and the OK button one after another into a single column
    cp12.setLayout(new GridLayout(4, 1));
    cp12.add(rb11);
    cp12.add(rb12);
    cp12.add(rb13);
    cp12.add(p1);
    // add three containers
    cp1.add(cp11);
    cp1.add(cp12);
    cp1.add(cp13);

    // dialog d2

    d2 = new JDialog(f1);
    d2.setBounds(132, 132, 300, 200);
    d2.addWindowListener(closeWindow);
    JLabel l2 = new JLabel("Enter your name: ");
    l2.setHorizontalAlignment(SwingConstants.CENTER);
    tf2 = new JTextField(12);
    JButton b2 = new JButton("OK");
    b2.setHorizontalAlignment(SwingConstants.CENTER);
    b2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //pass a name into the document modal dialog
            l3.setText("by " + tf2.getText());
            d3.setVisible(true);
        }
    });
    Container cp2 = d2.getContentPane();
    // add label, text field and button one after another into a single column
    cp2.setLayout(new BorderLayout());
    cp2.add(l2, BorderLayout.NORTH);
    cp2.add(tf2, BorderLayout.CENTER);
    JPanel p2 = new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(b2);
    cp2.add(p2, BorderLayout.SOUTH);

    // dialog d3

    d3 = new JDialog(d2, "", Dialog.ModalityType.DOCUMENT_MODAL);
    d3.setBounds(232, 232, 300, 200);
    d3.addWindowListener(closeWindow);
    JTextArea ta3 = new JTextArea();
    l3 = new JLabel();
    l3.setHorizontalAlignment(SwingConstants.RIGHT);
    Container cp3 = d3.getContentPane();
    cp3.setLayout(new BorderLayout());
    cp3.add(new JScrollPane(ta3), BorderLayout.CENTER);
    JPanel p3 = new JPanel();
    p3.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p3.add(l3);
    cp3.add(p3, BorderLayout.SOUTH);

    // second document

    // frame f4

    f4 = new JFrame("Book 2 (parent frame)");
    f4.setBounds(sw - 300 - 32, 32, 300, 200);
    f4.addWindowListener(closeWindow);
    // create radio buttons
    rb41 = new JRadioButton("Biography", true);
    rb42 = new JRadioButton("Funny tale", false);
    rb43 = new JRadioButton("Sonnets", false);
    // place radio buttons into a single group
    ButtonGroup bg4 = new ButtonGroup();
    bg4.add(rb41);
    bg4.add(rb42);
    bg4.add(rb43);
    JButton b4 = new JButton("OK");
    b4.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // get label of selected radiobutton
            String title = null;
            if (rb41.isSelected()) {
                title = rb41.getText();
            } else if (rb42.isSelected()) {
                title = rb42.getText();
            } else {
                title = rb43.getText();
            }
            // prepend radiobutton label to dialogs' titles
            d5.setTitle(title + " (modeless dialog)");
            d6.setTitle(title + " (document-modal dialog)");
            d5.setVisible(true);
        }
    });
    Container cp4 = f4.getContentPane();
    // create three containers to improve layouting
    cp4.setLayout(new GridLayout(1, 3));
    Container cp41 = new Container();
    Container cp42 = new Container();
    Container cp43 = new Container();
    // add the button into a separate panel
    JPanel p4 = new JPanel();
    p4.setLayout(new FlowLayout());
    p4.add(b4);
    // add radiobuttons and the OK button one after another into a single column
    cp42.setLayout(new GridLayout(4, 1));
    cp42.add(rb41);
    cp42.add(rb42);
    cp42.add(rb43);
    cp42.add(p4);
    //add three containers
    cp4.add(cp41);
    cp4.add(cp42);
    cp4.add(cp43);

    // dialog d5

    d5 = new JDialog(f4);
    d5.setBounds(sw - 400 - 32, 132, 300, 200);
    d5.addWindowListener(closeWindow);
    JLabel l5 = new JLabel("Enter your name: ");
    l5.setHorizontalAlignment(SwingConstants.CENTER);
    tf5 = new JTextField(12);
    tf5.setHorizontalAlignment(SwingConstants.CENTER);
    JButton b5 = new JButton("OK");
    b5.setHorizontalAlignment(SwingConstants.CENTER);
    b5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //pass a name into the document modal dialog
            l6.setText("by " + tf5.getText());
            d6.setVisible(true);
        }
    });
    Container cp5 = d5.getContentPane();
    // add label, text field and button one after another into a single column
    cp5.setLayout(new BorderLayout());
    cp5.add(l5, BorderLayout.NORTH);
    cp5.add(tf5, BorderLayout.CENTER);
    JPanel p5 = new JPanel();
    p5.setLayout(new FlowLayout());
    p5.add(b5);
    cp5.add(p5, BorderLayout.SOUTH);

    // dialog d6

    d6 = new JDialog(d5, "", Dialog.ModalityType.DOCUMENT_MODAL);
    d6.setBounds(sw - 500 - 32, 232, 300, 200);
    d6.addWindowListener(closeWindow);
    JTextArea ta6 = new JTextArea();
    l6 = new JLabel();
    l6.setHorizontalAlignment(SwingConstants.RIGHT);
    Container cp6 = d6.getContentPane();
    cp6.setLayout(new BorderLayout());
    cp6.add(new JScrollPane(ta6), BorderLayout.CENTER);
    JPanel p6 = new JPanel();
    p6.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p6.add(l6);
    cp6.add(p6, BorderLayout.SOUTH);

    // third document

    // frame f7

    f7 = new JFrame("Classics (excluded frame)");
    f7.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
    f7.setBounds(32, sh - 200 - 32, 300, 200);
    f7.addWindowListener(closeWindow);
    JLabel l7 = new JLabel("Famous writers: ");
    l7.setHorizontalAlignment(SwingConstants.CENTER);
    // create radio buttons
    rb71 = new JRadioButton("Burns", true);
    rb72 = new JRadioButton("Dickens", false);
    rb73 = new JRadioButton("Twain", false);
    // place radio buttons into a single group
    ButtonGroup bg7 = new ButtonGroup();
    bg7.add(rb71);
    bg7.add(rb72);
    bg7.add(rb73);
    Container cp7 = f7.getContentPane();
    // create three containers to improve layouting
    cp7.setLayout(new GridLayout(1, 3));
    Container cp71 = new Container();
    Container cp72 = new Container();
    Container cp73 = new Container();
    // add the label into a separate panel
    JPanel p7 = new JPanel();
    p7.setLayout(new FlowLayout());
    p7.add(l7);
    // add a label and radio buttons one after another into a single column
    cp72.setLayout(new GridLayout(4, 1));
    cp72.add(p7);
    cp72.add(rb71);
    cp72.add(rb72);
    cp72.add(rb73);
    // add three containers
    cp7.add(cp71);
    cp7.add(cp72);
    cp7.add(cp73);

    // fourth document

    // frame f8

    f8 = new JFrame("Feedback (parent frame)");
    f8.setBounds(sw - 300 - 32, sh - 200 - 32, 300, 200);
    f8.addWindowListener(closeWindow);
    JButton b8 = new JButton("Rate yourself");
    b8.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showConfirmDialog(null, "I really like my book", "Question (application-modal dialog)",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        }
    });
    Container cp8 = f8.getContentPane();
    cp8.setLayout(new FlowLayout(FlowLayout.CENTER, 8, 8));
    cp8.add(b8);
}

From source file:org.openmicroscopy.shoola.agents.util.SelectionWizard.java

/** 
 * Builds and lays out the UI.//ww w.  j  a va  2  s  .c  om
 * 
 * @param addCreation Pass <code>true</code> to add a component
 *                    allowing creation of object of the passed type,
 *                    <code>false</code> otherwise.
 */
private void buildUI(boolean addCreation) {
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
    container.add(uiDelegate);
    container.add(createFilteringControl());
    if (addCreation && TagAnnotationData.class.equals(type)) {
        container.add(createAdditionPane());
    }
    c.add(container, BorderLayout.CENTER);
    c.add(createControlsPane(), BorderLayout.SOUTH);
}

From source file:no.eris.applet.AppletViewer.java

/**
 * Runs the applet. Creates a Frame and adds it to it.
 * @param async whether to start a separate thread running the viewer.
 * @return the started thread or <code>null</code> when async is false
 *//*from w w  w .j av  a2 s  .  c om*/
public Thread run(final boolean async) {

    overrideCookieHandler(manager);

    frame = new JFrame("AppletViewer");
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            LOGGER.debug("windowClosing");
            disposeResources();
        }
    });

    Container cp = frame.getContentPane();
    cp.setLayout(new BorderLayout());

    // Instantiate the AppletAdapter which gives us
    // AppletStub and AppletContext.
    if (appletAdapter == null)
        appletAdapter = new AppletAdapter(this, attributes, params);

    // The AppletAdapter also gives us showStatus.
    // Therefore, must add() it very early on, since the Applet's
    // Constructor or its init() may use showStatus()
    cp.add(BorderLayout.SOUTH, appletAdapter);

    showStatus("Loading Applet ");
    if (loadFromLocalClasspath) {
        loadAppletLocaly();
    } else {
        loadAppletRemotely();
    }
    setAppletSize();

    if (applet == null) {
        LOGGER.debug("applet null");
        return null;
    }

    // Now right away, tell the Applet how to find showStatus et al.
    applet.setStub(appletAdapter);

    // Connect the Applet to the Frame.
    cp.add(BorderLayout.CENTER, applet);

    threadGroup = new ThreadGroup("AppletViewer-" + applet.getParameter("name") + "-FIXME_ID");
    threadGroup.setDaemon(true);

    // Here we pretend to be a browser!
    final Runnable task = new Runnable() {
        public void run() {
            applet.init();
            final Dimension d = applet.getSize();
            d.height += appletAdapter.getSize().height;
            frame.setSize(d);
            frame.setVisible(true); // make the Frame and all in it appear
            applet.start();
            showStatus("Applet " + applet.getParameter("name") + " loaded");
            if (async) {
                waitForAppletToClose();
            }
        }
    };
    if (async) {
        Thread t = new Thread(threadGroup, task);
        final ClassLoader loader = applet.getClass().getClassLoader();
        t.setContextClassLoader(loader);
        t.start();
        return t;
    } else {
        task.run();
        return null;
    }
}

From source file:de.huxhorn.lilith.swing.preferences.PreferencesDialog.java

private void createUI() {
    generalPanel = new GeneralPanel(this);
    startupShutdownPanel = new StartupShutdownPanel(this);
    windowsPanel = new WindowsPanel(this);
    soundsPanel = new SoundsPanel(this);
    sourcesPanel = new SourcesPanel(this);
    sourceListsPanel = new SourceListsPanel(this);
    sourceFilteringPanel = new SourceFilteringPanel(this);
    conditionsPanel = new ConditionsPanel(this);
    loggingLevelPanel = new LoggingLevelPanel(this);
    accessStatusTypePanel = new AccessStatusTypePanel(this);
    TroubleshootingPanel troubleshootingPanel = new TroubleshootingPanel(this);

    comboBoxModel = new DefaultComboBoxModel<>();
    for (Panes current : Panes.values()) {
        comboBoxModel.addElement(current);
    }//  www  . ja v a 2s  . c  o m
    comboBox = new JComboBox<>(comboBoxModel);
    comboBox.setRenderer(new MyComboBoxRenderer());
    comboBox.setEditable(false);
    comboBox.addItemListener(new ComboItemListener());

    cardLayout = new CardLayout();
    content = new JPanel(cardLayout);
    content.setPreferredSize(new Dimension(600, 500));

    content.add(generalPanel, Panes.General.toString());
    content.add(startupShutdownPanel, Panes.StartupShutdown.toString());
    content.add(windowsPanel, Panes.Windows.toString());
    content.add(soundsPanel, Panes.Sounds.toString());
    content.add(sourcesPanel, Panes.Sources.toString());
    content.add(sourceListsPanel, Panes.SourceLists.toString());
    content.add(sourceFilteringPanel, Panes.SourceFiltering.toString());
    content.add(conditionsPanel, Panes.Conditions.toString());
    content.add(loggingLevelPanel, Panes.LoggingLevels.toString());
    content.add(accessStatusTypePanel, Panes.AccessStatus.toString());
    content.add(troubleshootingPanel, Panes.Troubleshooting.toString());

    // Main buttons
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    OkAction okAction = new OkAction();
    buttonPanel.add(new JButton(okAction));
    buttonPanel.add(new JButton(new ApplyAction()));
    buttonPanel.add(new JButton(new ResetAction()));
    CancelAction cancelAction = new CancelAction();
    buttonPanel.add(new JButton(cancelAction));

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(comboBox, BorderLayout.NORTH);
    contentPane.add(content, BorderLayout.CENTER);
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    KeyStrokes.registerCommand(content, okAction, "OK_ACTION");
    KeyStrokes.registerCommand(buttonPanel, okAction, "OK_ACTION");
    KeyStrokes.registerCommand(content, cancelAction, "CANCEL_ACTION");
    KeyStrokes.registerCommand(buttonPanel, cancelAction, "CANCEL_ACTION");
}