Example usage for javax.swing JPanel setPreferredSize

List of usage examples for javax.swing JPanel setPreferredSize

Introduction

In this page you can find the example usage for javax.swing JPanel setPreferredSize.

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

From source file:Clavis.Windows.WShedule.java

public synchronized void create() {
    initComponents();//from www  .  j a  va 2 s .  c  o m
    this.setModal(true);
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            close();
        }
    });
    this.setTitle(lingua.translate("Registos de emprstimo para o recurso") + ": "
            + lingua.translate(mat.getTypeOfMaterialName()).toLowerCase() + " "
            + lingua.translate(mat.getDescription()));
    KeyQuest.addtoPropertyListener(jPanelInicial, true);
    String dat = new TimeDate.Date().toString();
    String[] auxiliar = prefs.get("datainicio", dat).split("/");
    if (auxiliar[0].length() > 1) {
        if (auxiliar[0].charAt(0) == '0') {
            auxiliar[0] = auxiliar[0].replaceFirst("0", "");
        }
    }
    if (auxiliar[1].length() > 1) {
        if (auxiliar[1].charAt(0) == '0') {
            auxiliar[1] = auxiliar[1].replaceFirst("0", "");
        }
    }
    if (auxiliar[2].length() > 1) {
        if (auxiliar[2].charAt(0) == '0') {
            auxiliar[2] = auxiliar[2].replaceFirst("0", "");
        }
    }
    inicio = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]),
            Integer.valueOf(auxiliar[2]));
    auxiliar = prefs.get("datafim", dat).split("/");
    if (auxiliar[0].length() > 1) {
        if (auxiliar[0].charAt(0) == '0') {
            auxiliar[0] = auxiliar[0].replaceFirst("0", "");
        }
    }
    if (auxiliar[1].length() > 1) {
        if (auxiliar[1].charAt(0) == '0') {
            auxiliar[1] = auxiliar[1].replaceFirst("0", "");
        }
    }
    if (auxiliar[2].length() > 1) {
        if (auxiliar[2].charAt(0) == '0') {
            auxiliar[2] = auxiliar[2].replaceFirst("0", "");
        }
    }
    fim = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]),
            Integer.valueOf(auxiliar[2]));

    SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy");
    Date date;
    try {
        date = sdf.parse(fim.toString());
    } catch (ParseException ex) {
        date = new Date();

    }
    jXDatePickerFim.setDate(date);
    try {
        date = sdf.parse(inicio.toString());
    } catch (ParseException ex) {
        date = new Date();
    }
    jXDatePickerInicio.setDate(date);
    andamento = 0;
    if (DataBase.DataBase.testConnection(url)) {
        DataBase.DataBase db = new DataBase.DataBase(url);
        java.util.List<Keys.Request> requisicoes = Clavis.RequestList
                .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim));
        db.close();
        estado = lingua.translate("Todos");
        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
        if (requisicoes.size() > 0) {
            valores = new String[requisicoes.size()][4];
            lista = new java.util.ArrayList<>();
            requisicoes.stream().map((req) -> {
                if (mat.getMaterialTypeID() == 1) {
                    valores[andamento][0] = req.getPerson().getName();
                    valores[andamento][1] = req.getTimeBegin().toString(0) + " - "
                            + req.getTimeEnd().toString(0);
                    valores[andamento][2] = req.getBeginDate().toString();
                    String[] multipla = req.getActivity().split(":::");
                    if (multipla.length > 1) {
                        Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                        pop.create();
                        jTable1.addMouseListener(new MouseAdapter() {
                            int x = andamento;
                            int y = 3;

                            @Override
                            public void mousePressed(MouseEvent e) {
                                if (e.getButton() == MouseEvent.BUTTON1) {
                                    int row = jTable1.rowAtPoint(e.getPoint());
                                    int col = jTable1.columnAtPoint(e.getPoint());
                                    if ((row == x) && (col == y)) {
                                        pop.show(e.getComponent(), e.getX(), e.getY());
                                    }
                                }
                            }

                            @Override
                            public void mouseReleased(MouseEvent e) {
                                if (e.getButton() == MouseEvent.BUTTON1) {
                                    if (pop.isShowing()) {
                                        pop.setVisible(false);
                                    }
                                }
                            }
                        });
                        valores[andamento][3] = lingua.translate(multipla[0]) + "";
                    } else {
                        valores[andamento][3] = lingua.translate(req.getActivity());
                    }
                    if (valores[andamento][3].equals("")) {
                        valores[andamento][3] = lingua.translate("Sem descrio");
                    }
                    Object[] ob = { req.getPerson().getName(),
                            req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0),
                            req.getBeginDate().toString(), valores[andamento][3], req.getSubject().getName() };
                    modelo.addRow(ob);
                } else {
                    valores[andamento][0] = req.getPerson().getName();
                    valores[andamento][1] = req.getBeginDate().toString();
                    valores[andamento][2] = req.getEndDate().toString();
                    String[] multipla = req.getActivity().split(":::");
                    if (multipla.length > 1) {
                        Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                        pop.create();
                        jTable1.addMouseListener(new MouseAdapter() {
                            int x = andamento;
                            int y = 3;

                            @Override
                            public void mousePressed(MouseEvent e) {
                                if (e.getButton() == MouseEvent.BUTTON1) {
                                    int row = jTable1.rowAtPoint(e.getPoint());
                                    int col = jTable1.columnAtPoint(e.getPoint());
                                    if ((row == x) && (col == y)) {
                                        pop.show(e.getComponent(), e.getX(), e.getY());
                                    }
                                }
                            }

                            @Override
                            public void mouseReleased(MouseEvent e) {
                                if (e.getButton() == MouseEvent.BUTTON1) {
                                    if (pop.isShowing()) {
                                        pop.setVisible(false);
                                    }
                                }
                            }
                        });
                        valores[andamento][3] = multipla[0];
                    } else {
                        valores[andamento][3] = lingua.translate(req.getActivity());
                    }
                    if (valores[andamento][3].equals("")) {
                        valores[andamento][3] = lingua.translate("Sem descrio");
                    }
                    Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(),
                            req.getEndDate().toString(), valores[andamento][3] };
                    modelo.addRow(ob);
                }
                return req;
            }).map((req) -> {
                lista.add(req);
                return req;
            }).forEach((_item) -> {
                andamento++;
            });
        }
    }
    jComboBoxEstado.setSelectedIndex(prefs.getInt("comboboxvalue", 0));
    String[] opcoes = { lingua.translate("Ver detalhes da requisio"),
            lingua.translate("Ver requisices com a mesma data"),
            lingua.translate("Ver requisices com o mesmo estado") };
    ActionListener[] eventos = new ActionListener[opcoes.length];
    eventos[0] = (ActionEvent r) -> {
        Border border = BorderFactory.createCompoundBorder(
                BorderFactory.createCompoundBorder(new org.jdesktop.swingx.border.DropShadowBorder(Color.BLACK,
                        3, 0.5f, 6, false, false, true, true), BorderFactory.createLineBorder(Color.BLACK, 1)),
                BorderFactory.createEmptyBorder(0, 10, 0, 10));
        int val = jTable1.getSelectedRow();
        Keys.Request req = lista.get(val);
        javax.swing.JPanel pan = new javax.swing.JPanel(null);
        pan.setPreferredSize(new Dimension(500, 300));
        pan.setBounds(0, 20, 500, 400);
        pan.setBackground(Components.MessagePane.BACKGROUND_COLOR);
        javax.swing.JLabel lrecurso1 = new javax.swing.JLabel(lingua.translate("Recurso") + ": ");
        lrecurso1.setBounds(10, 20, 120, 26);
        lrecurso1.setFocusable(true);
        lrecurso1.setHorizontalAlignment(javax.swing.JLabel.LEFT);
        pan.add(lrecurso1);
        javax.swing.JLabel lrecurso11 = new javax.swing.JLabel(
                lingua.translate(req.getMaterial().getTypeOfMaterialName()) + " "
                        + lingua.translate(req.getMaterial().getDescription()));
        lrecurso11.setBounds(140, 20, 330, 26);
        lrecurso11.setBorder(border);
        pan.add(lrecurso11);
        javax.swing.JLabel lrecurso2 = new javax.swing.JLabel(lingua.translate("Utilizador") + ": ");
        lrecurso2.setBounds(10, 50, 120, 26);
        lrecurso2.setFocusable(true);
        lrecurso2.setHorizontalAlignment(javax.swing.JLabel.LEFT);
        pan.add(lrecurso2);
        javax.swing.JLabel lrecurso22 = new javax.swing.JLabel(req.getPerson().getName());
        lrecurso22.setBounds(140, 50, 330, 26);
        lrecurso22.setBorder(border);
        pan.add(lrecurso22);
        javax.swing.JLabel lrecurso3 = new javax.swing.JLabel(lingua.translate("Data inicial") + ": ");
        lrecurso3.setBounds(10, 80, 120, 26);
        lrecurso3.setFocusable(true);
        lrecurso3.setHorizontalAlignment(javax.swing.JLabel.LEFT);
        pan.add(lrecurso3);
        javax.swing.JLabel lrecurso33 = new javax.swing.JLabel(
                req.getBeginDate().toStringWithMonthWord(lingua));
        lrecurso33.setBounds(140, 80, 330, 26);
        lrecurso33.setBorder(border);
        pan.add(lrecurso33);
        javax.swing.JLabel lrecurso4 = new javax.swing.JLabel(lingua.translate("Data final") + ": ");
        lrecurso4.setBounds(10, 110, 120, 26);
        lrecurso4.setFocusable(true);
        lrecurso4.setHorizontalAlignment(javax.swing.JLabel.LEFT);
        pan.add(lrecurso4);
        javax.swing.JLabel lrecurso44 = new javax.swing.JLabel(req.getEndDate().toStringWithMonthWord(lingua));
        lrecurso44.setBounds(140, 110, 330, 26);
        lrecurso44.setBorder(border);
        pan.add(lrecurso44);

        javax.swing.JLabel lrecurso5 = new javax.swing.JLabel(lingua.translate("Atividade") + ": ");
        lrecurso5.setBounds(10, 140, 120, 26);
        lrecurso5.setFocusable(true);
        lrecurso5.setHorizontalAlignment(javax.swing.JLabel.LEFT);
        pan.add(lrecurso5);
        javax.swing.JLabel lrecurso55;
        if (req.getActivity().equals("")) {
            lrecurso55 = new javax.swing.JLabel(lingua.translate("Sem descrio"));
        } else {
            String[] saux = req.getActivity().split(":::");
            String atividade;
            boolean situacao = false;
            if (saux.length > 1) {
                situacao = true;
                atividade = saux[0];
            } else {
                atividade = req.getActivity();
            }
            if (req.getSubject().getId() > 0) {
                lrecurso55 = new javax.swing.JLabel(
                        lingua.translate(atividade) + ": " + req.getSubject().getName());
            } else {
                lrecurso55 = new javax.swing.JLabel(lingua.translate(atividade));
            }
            if (situacao) {
                Components.PopUpMenu pop = new Components.PopUpMenu(saux, lingua);
                pop.create();
                lrecurso55.addMouseListener(new MouseAdapter() {

                    @Override
                    public void mouseEntered(MouseEvent e) {
                        pop.show(e.getComponent(), e.getX(), e.getY());
                    }

                    @Override
                    public void mouseExited(MouseEvent e) {
                        pop.setVisible(false);
                    }

                });
            }
        }
        lrecurso55.setBounds(140, 140, 330, 26);
        lrecurso55.setBorder(border);
        pan.add(lrecurso55);
        int distancia = 170;
        if (req.getBeginDate().isBigger(req.getEndDate()) == 0) {
            javax.swing.JLabel lrecurso6 = new javax.swing.JLabel(lingua.translate("Horrio") + ": ");
            lrecurso6.setBounds(10, distancia, 120, 26);
            lrecurso6.setFocusable(true);
            lrecurso6.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            pan.add(lrecurso6);
            javax.swing.JLabel lrecurso66 = new javax.swing.JLabel(
                    req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0));
            lrecurso66.setBounds(140, distancia, 330, 26);
            lrecurso66.setBorder(border);
            pan.add(lrecurso66);
            distancia = 200;
        }
        if (req.getBeginDate().isBigger(req.getEndDate()) == 0) {
            javax.swing.JLabel lrecurso7 = new javax.swing.JLabel(lingua.translate("Dia da semana") + ": ");
            lrecurso7.setBounds(10, distancia, 120, 26);
            lrecurso7.setFocusable(true);
            lrecurso7.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            pan.add(lrecurso7);
            javax.swing.JLabel lrecurso77 = new javax.swing.JLabel(
                    lingua.translate(req.getWeekDay().perDayName()));
            lrecurso77.setBounds(140, distancia, 330, 26);
            lrecurso77.setBorder(border);
            pan.add(lrecurso77);
            if (distancia == 200) {
                distancia = 230;
            } else {
                distancia = 200;
            }
        }
        if (req.isTerminated() || req.isActive()) {
            javax.swing.JLabel lrecurso8 = new javax.swing.JLabel(lingua.translate("Levantamento") + ": ");
            lrecurso8.setBounds(10, distancia, 120, 26);
            lrecurso8.setFocusable(true);
            lrecurso8.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            pan.add(lrecurso8);
            javax.swing.JLabel lrecurso88;
            if ((req.getLiftDate() != null) && (req.getLiftTime() != null)) {
                lrecurso88 = new javax.swing.JLabel(req.getLiftDate().toString() + " " + lingua.translate("s")
                        + " " + req.getLiftTime().toString(0));
            } else {
                lrecurso88 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar"));
            }
            lrecurso88.setBounds(140, distancia, 330, 26);
            lrecurso88.setBorder(border);
            pan.add(lrecurso88);
            switch (distancia) {
            case 200:
                distancia = 230;
                break;
            case 230:
                distancia = 260;
                break;
            default:
                distancia = 200;
                break;
            }
        }
        if (req.isTerminated()) {
            javax.swing.JLabel lrecurso9 = new javax.swing.JLabel(lingua.translate("Entrega") + ": ");
            lrecurso9.setBounds(10, distancia, 120, 26);
            lrecurso9.setFocusable(true);
            lrecurso9.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            pan.add(lrecurso9);
            javax.swing.JLabel lrecurso99;
            if ((req.getDeliveryDate() != null) && (req.getDeliveryTime() != null)) {
                lrecurso99 = new javax.swing.JLabel(req.getDeliveryDate().toString() + " "
                        + lingua.translate("s") + " " + req.getDeliveryTime().toString(0));
            } else {
                lrecurso99 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar"));
            }
            lrecurso99.setBounds(140, distancia, 330, 26);
            lrecurso99.setBorder(border);
            pan.add(lrecurso99);
            switch (distancia) {
            case 200:
                distancia = 230;
                break;
            case 230:
                distancia = 260;
                break;
            case 260:
                distancia = 290;
                break;
            default:
                distancia = 200;
                break;
            }
        }
        Components.MessagePane mensagem = new Components.MessagePane(this, Components.MessagePane.INFORMACAO,
                Clavis.KeyQuest.getSystemColor(), lingua.translate(""), 500, 400, pan, "",
                new String[] { lingua.translate("Voltar") });
        mensagem.showMessage();
    };
    eventos[1] = (ActionEvent r) -> {
        String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 2).toString();
        SimpleDateFormat sdf_auxiliar = new SimpleDateFormat("dd/MM/yyyy");
        Date data_auxiliar;
        try {
            data_auxiliar = sdf_auxiliar.parse(val);
            Calendar cal = Calendar.getInstance();
            cal.setTime(data_auxiliar);
            int dia = cal.get(Calendar.DAY_OF_MONTH);
            int mes = cal.get(Calendar.MONTH) + 1;
            int ano = cal.get(Calendar.YEAR);
            inicio = new TimeDate.Date(dia, mes, ano);
            fim = new TimeDate.Date(dia, mes, ano);
        } catch (ParseException ex) {
            data_auxiliar = new Date();
        }
        jXDatePickerFim.setDate(data_auxiliar);
        jXDatePickerInicio.setDate(data_auxiliar);
        refreshTable(jComboBoxEstado.getSelectedIndex());
    };
    eventos[2] = (ActionEvent r) -> {
        String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 3).toString();
        for (int i = 0; i < jComboBoxEstado.getItemCount(); i++) {
            if (jComboBoxEstado.getItemAt(i).equals(val)) {
                jComboBoxEstado.setSelectedIndex(i);
            }
        }
    };
    KeyStroke[] strokes = new KeyStroke[opcoes.length];
    strokes[0] = KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK);
    strokes[1] = KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK);
    strokes[2] = KeyStroke.getKeyStroke(KeyEvent.VK_E, Event.CTRL_MASK);
    Components.PopUpMenu pop = new Components.PopUpMenu(opcoes, eventos, strokes);
    pop.create();
    mouseaction = new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY());
            if (jTable1.rowAtPoint(ponto) > -1) {
                jTable1.setRowSelectionInterval(jTable1.rowAtPoint(ponto),
                        jTable1.rowAtPoint(new java.awt.Point(e.getX(), e.getY())));
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                if (jTable1.getSelectedRow() >= 0) {
                    java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY());
                    if (jTable1.rowAtPoint(ponto) > -1) {
                        pop.show(e.getComponent(), e.getX(), e.getY());
                    }
                }
            }
        }

    };
    jTable1.addMouseListener(mouseaction);
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.objeto.PainelObjeto.java

private void initComponentsEscalavel(

        ArrayList<FerramentaDescricaoModel> erros) {
    Ferramenta_Objetos.carregaTexto(TokenLang.LANG);
    JPanel regraFonteBtn = new JPanel();
    regraFonteBtn.setLayout(new BorderLayout());

    scrollPaneDescricao = new G_TextAreaSourceCode();
    scrollPaneDescricao.setTipoHTML();/* w ww  .  j  a va 2  s  .  c om*/
    new OnChange(scrollPaneDescricao, this);
    //parentFrame.setJMenuBar(this.criaMenuBar());

    // parentFrame.setTitle("Associador de rtulos");
    tableLinCod = new TabelaDescricao(erros);
    arTextPainelCorrecao = new ArTextPainelCorrecao();

    // scrollPaneCorrecaoLabel = new ConteudoCorrecaoLabel();

    salvar = new JButton();
    abrir = new JButton();
    cancelar = new JButton();
    strConteudoalt = new String();
    // panelLegenda = new JPanel();

    pnRegra = new JPanel();
    lbRegras1 = new JLabel();
    lbRegras2 = new JLabel();
    pnSetaDescricao = new JPanel();
    pnSetaDescricao.setLayout(new BorderLayout());
    spTextoDescricao = new JScrollPane();
    tArParticipRotulo = new TArParticipRotulo();
    conteudoDoAlt = new JTextArea();
    pnListaErros = new JPanel();
    scrollPanetabLinCod = new JScrollPane();
    lbTemp = new JLabel();
    pnBotoes = new JPanel();
    btnSalvar = new JMenuItem(GERAL.BTN_SALVAR);

    adicionar = new JButton();
    conteudoParticRotulo = new ArrayList<String>();
    // setJMenuBar(this.criaMenuBar());
    // ======== this ========
    // setTitle("Associe explicitamente os r\u00f3tulos aos respectivos
    // controles:");
    salvar.setEnabled(false);
    salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(scrollPaneDescricao.getTextPane(), salvar,
            new JMenuItem(), parentFrame);
    setBackground(CoresDefault.getCorPaineis());
    Container contentPane = this;// ??
    contentPane.setLayout(new GridLayout(2, 1));

    // ======== pnRegra ========
    {
        pnRegra.setBorder(criaBorda(Ferramenta_Objetos.TITULO_REGRA));
        pnRegra.setLayout(new GridLayout(2, 1));
        pnRegra.add(lbRegras1);
        lbRegras1.setText(Ferramenta_Objetos.REGRAP1);
        lbRegras2.setText(Ferramenta_Objetos.REGRAP2);
        lbRegras1.setHorizontalAlignment(SwingConstants.CENTER);

        lbRegras2.setHorizontalAlignment(SwingConstants.CENTER);
        pnRegra.add(lbRegras1);
        pnRegra.add(lbRegras2);
        pnRegra.setPreferredSize(new Dimension(700, 60));
    }

    // G_URLIcon.setIcon(lbTemp,
    // "http://pitecos.blogs.sapo.pt/arquivo/pai%20natal%20o5.%20jpg.jpg");

    // ======== pnDescricao ========

    // ---- Salvar ----
    salvar.setText(Ferramenta_Objetos.BTN_SALVAR);
    salvar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            salvarActionPerformed(e);
        }
    });

    salvar.setToolTipText(Ferramenta_Objetos.DICA_SALVAR);
    salvar.getAccessibleContext().setAccessibleDescription(Ferramenta_Objetos.DICA_SALVAR);
    salvar.getAccessibleContext().setAccessibleName(Ferramenta_Objetos.DICA_SALVAR);
    salvar.setBounds(10, 0, 150, 25);

    abrir.setText(Ferramenta_Objetos.BTN_ABRIR);
    abrir.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AbrirActionPerformed(e);
        }
    });

    abrir.setToolTipText(Ferramenta_Objetos.DICA_ABRIR);
    abrir.getAccessibleContext().setAccessibleDescription(Ferramenta_Objetos.DICA_ABRIR_HTML);
    abrir.getAccessibleContext().setAccessibleName(Ferramenta_Objetos.DICA_ABRIR_HTML);
    abrir.setBounds(165, 0, 150, 25);

    cancelar.setText(Ferramenta_Objetos.TELA_ANTERIOR);
    cancelar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CancelarActionPerformed(e);
        }
    });

    cancelar.setToolTipText(Ferramenta_Objetos.DICA_TELA_ANTERIOR);
    cancelar.getAccessibleContext().setAccessibleDescription(Ferramenta_Objetos.DICA_TELA_ANTERIOR);
    cancelar.getAccessibleContext().setAccessibleName(Ferramenta_Objetos.DICA_TELA_ANTERIOR);
    cancelar.setBounds(320, 0, 150, 25);

    // ======== pnParticRotulo ========

    // pnSetaDescricao.setBorder(criaBorda(Ferramenta_Imagens.TITULO_DIGITE_O_ALT));

    // ======== spParticRotulo ========
    {
        // spTextoDescricao.setViewportView(conteudoDoAlt);
    }

    // lbRegras1.setText(Reparo_Imagens.REGRAP2);
    // lbRegras1.setHorizontalAlignment(SwingConstants.CENTER);

    // pnRegra.add(lbRegras1);

    JScrollPane sp = new JScrollPane();

    sp.setViewportView(conteudoDoAlt);
    sp.setPreferredSize(new Dimension(500, 300));
    sp.setBorder(criaBorda(Ferramenta_Objetos.CONTEUDO_ALTER));
    // pnSetaDescricao.add(spTextoDescricao,cons);

    pnSetaDescricao.setPreferredSize(new Dimension(400, 60));

    // ======== pnListaErros ========
    {

        pnListaErros.setBorder(criaBorda(Ferramenta_Objetos.LISTA_ERROS));
        pnListaErros.setLayout(new BorderLayout());
        // ======== scrollPanetabLinCod ========
        {
            scrollPanetabLinCod.setViewportView(tableLinCod);
        }
        pnListaErros.add(scrollPanetabLinCod, BorderLayout.CENTER);
    }
    // ======== pnBotoes ========
    {

        // pnBotoes.setBorder(criaBorda(""));

        pnBotoes.setLayout(null);
        // ---- adicionar ----
        adicionar.setText(Ferramenta_Objetos.BTN_ADICIONAR);
        adicionar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                adicionarActionPerformed(e);
            }
        });
    }

    /*
     * Colocar os controles
     */
    pnRegra.setBackground(CoresDefault.getCorPaineis());
    regraFonteBtn.add(pnRegra, BorderLayout.NORTH);
    scrollPaneDescricao.setBorder(criaBorda(""));
    scrollPaneDescricao.setBackground(CoresDefault.getCorPaineis());

    JSplitPane splitPane = null;

    Dimension minimumSize = new Dimension(0, 0);
    // JScrollPane ajudaScrollPane = new
    // JScrollPane(ajuda,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    sp.setMinimumSize(minimumSize);
    sp.setPreferredSize(new Dimension(150, 90));
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp, scrollPaneDescricao);
    splitPane.setOneTouchExpandable(true);
    // splitPane.set
    // splitPane.setDividerLocation(0.95);
    int w = parentFrame.getWidth();
    int s = w / 4;
    splitPane.setDividerLocation(s);

    // regraFonteBtn.add(scrollPaneCorrecaoLabel, BorderLayout.CENTER);
    regraFonteBtn.add(splitPane, BorderLayout.CENTER);
    pnBotoes.setPreferredSize(new Dimension(600, 35));
    pnBotoes.setBackground(CoresDefault.getCorPaineis());
    // regraFonteBtn.add(pnBotoes, BorderLayout.SOUTH);
    regraFonteBtn.setBackground(CoresDefault.getCorPaineis());
    contentPane.add(regraFonteBtn);

    JPanel textoErrosBtn = new JPanel();
    textoErrosBtn.setLayout(new BorderLayout());
    pnSetaDescricao.setBackground(CoresDefault.getCorPaineis());
    pnSetaDescricao.add(pnBotoes);
    aplicar = new JButton();
    aplicar.setBounds(3, 3, 120, 30);
    pnBotoes.add(aplicar);

    // ---- aplicarRotulo ----
    aplicar.setEnabled(false);
    aplicar.setText(Ferramenta_Objetos.BTN_APLICAR);
    aplicar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            aplicarRotuloActionPerformed(e);
        }
    });

    aplicar.setToolTipText(Ferramenta_Objetos.DICA_APLICAR);
    aplicar.getAccessibleContext().setAccessibleDescription(Ferramenta_Objetos.DICA_APLICAR);
    aplicar.getAccessibleContext().setAccessibleName(Ferramenta_Objetos.DICA_APLICAR);
    textoErrosBtn.add(pnSetaDescricao, BorderLayout.NORTH);

    textoErrosBtn.add(pnListaErros, BorderLayout.CENTER);
    JPanel pnSalvarCancelar = new JPanel();
    pnSalvarCancelar.setLayout(null);
    pnSalvarCancelar.setPreferredSize(new Dimension(600, 35));
    pnSalvarCancelar.add(salvar);
    pnSalvarCancelar.add(abrir);
    pnSalvarCancelar.add(cancelar);

    if (!original) {
        reverter = new JButton("Reverter");
        reverter.setText(TradPainelRelatorio.REVERTER);
        reverter.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                setVisible(false);
                TxtBuffer.setContent(TxtBuffer.getContentOriginal());
                parentFrame.showPainelFerramentaDescricaoObjetosPArq(TxtBuffer.getContentOriginal());
                setVisible(true);
            }

        });
        //reverter.setActionCommand("Reverter");
        reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER);
        reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER);
        reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER);
        reverter.setBounds(485, 0, 150, 25);
        pnSalvarCancelar.add(reverter);
    }

    pnSalvarCancelar.setBackground(CoresDefault.getCorPaineis());
    textoErrosBtn.add(pnSalvarCancelar, BorderLayout.SOUTH);
    pnListaErros.setBackground(CoresDefault.getCorPaineis());
    textoErrosBtn.add(pnListaErros, BorderLayout.CENTER);
    contentPane.setBackground(CoresDefault.getCorPaineis());
    contentPane.add(textoErrosBtn);
    if (tableLinCod.getRowCount() == 0)
        tableLinCod.addLinha(0, 0, GERAL.DOC_SEM_ERROS);
    this.setVisible(true);

}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.label.PainelLabel.java

private void initComponentsEscalavel(ArrayList<FerramentaLabelModel> erros) {

    LabelPanel.carregaTexto(TokenLang.LANG);
    JPanel regraFonteBtn = new JPanel();
    regraFonteBtn.setLayout(new BorderLayout());

    textAreaSourceCode = new G_TextAreaSourceCode();
    textAreaSourceCode.setTipoHTML();//w  ww.  jav a  2  s. c  o  m

    //parentFrame.setJMenuBar(this.criaMenuBar());

    // parentFrame.setTitle("Associador de rtulos");
    tableLinCod = new TabelaCorrecaoLabel(erros);
    arTextPainelCorrecao = new ArTextPainelCorrecao();

    salvar = new JButton();
    salvar.setEnabled(false);
    //btnSalvar.setEnabled(false);
    abrir = new JButton();
    cancelar = new JButton();
    // panelLegenda = new JPanel();
    salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(textAreaSourceCode.getTextPane(), salvar,
            new JMenuItem(), parentFrame);
    new OnChange(textAreaSourceCode, this);

    pnRegra = new JPanel();
    lbRegras1 = new JLabel();
    lbRegras2 = new JLabel();
    pnParticRotulo = new JPanel();
    spParticRotulo = new JScrollPane();
    tArParticipRotulo = new TArParticipRotulo();

    pnListaErros = new JPanel();
    scrollPanetabLinCod = new JScrollPane();

    pnBotoes = new JPanel();

    adicionar = new JButton();
    aplicarRotulo = new JButton();
    conteudoParticRotulo = new ArrayList<String>();
    // setJMenuBar(this.criaMenuBar());
    // ======== this ========
    // setTitle("Associe explicitamente os r\u00f3tulos aos respectivos
    // controles:");

    setBackground(CoresDefault.getCorPaineis());
    Container contentPane = this;// ??
    contentPane.setLayout(new GridLayout(2, 1));

    // ======== pnRegra ========
    {
        pnRegra.setBorder(criaBorda(LabelPanel.TITULO_REGRA));
        pnRegra.setLayout(new GridLayout(2, 1));
        pnRegra.add(lbRegras1);
        lbRegras1.setText(LabelPanel.REGRAP1);
        lbRegras2.setText(LabelPanel.REGRAP2);
        lbRegras1.setHorizontalAlignment(SwingConstants.CENTER);
        lbRegras2.setHorizontalAlignment(SwingConstants.CENTER);
        pnRegra.add(lbRegras1);
        pnRegra.add(lbRegras2);
        pnRegra.setPreferredSize(new Dimension(700, 60));
    }

    // ======== pnDescricao ========
    {
        // ---- Salvar ----
        salvar.setText(GERAL.BTN_SALVAR);
        salvar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.out.println("btn_salvar.actionPerformed()");
                salvarActionPerformed(e);
            }
        });

        salvar.setToolTipText(GERAL.DICA_SALVAR);
        salvar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SALVAR);
        salvar.getAccessibleContext().setAccessibleName(GERAL.DICA_SALVAR);
        salvar.setBounds(10, 0, 150, 25);

        abrir.setText(GERAL.BTN_ABRIR);
        abrir.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                AbrirActionPerformed(e);
            }
        });

        abrir.setToolTipText(LabelPanel.DICA_ABRIR);
        abrir.getAccessibleContext().setAccessibleDescription(LabelPanel.DICA_ABRIR);
        abrir.getAccessibleContext().setAccessibleName(LabelPanel.DICA_ABRIR);
        abrir.setBounds(165, 0, 150, 25);

        cancelar.setText(LabelPanel.TELA_ANTERIOR);
        cancelar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                CancelarActionPerformed(e);
            }
        });

        cancelar.setToolTipText(LabelPanel.DICA_TELA_ANTERIOR);
        cancelar.getAccessibleContext().setAccessibleDescription(LabelPanel.DICA_TELA_ANTERIOR);
        cancelar.getAccessibleContext().setAccessibleName(LabelPanel.DICA_TELA_ANTERIOR);
        cancelar.setBounds(320, 0, 150, 25);

        // ======== pnParticRotulo ========
        {
            pnParticRotulo.setBorder(criaBorda(LabelPanel.TITULO_PARTCP_DO_ROTULO));
            pnParticRotulo.setLayout(new BorderLayout());

            // ======== spParticRotulo ========
            {
                spParticRotulo.setViewportView(tArParticipRotulo);
            }
            pnParticRotulo.add(spParticRotulo, BorderLayout.CENTER);
            pnParticRotulo.setPreferredSize(new Dimension(780, 80));
        }
        // ======== pnListaErros ========
        {

            pnListaErros.setBorder(criaBorda(LabelPanel.TITULO_TABELA));
            pnListaErros.setLayout(new BorderLayout());
            // ======== scrollPanetabLinCod ========
            {
                scrollPanetabLinCod.setViewportView(tableLinCod);
            }
            pnListaErros.add(scrollPanetabLinCod, BorderLayout.CENTER);
        }
        // ======== pnBotoes ========
        {

            // pnBotoes.setBorder(criaBorda(""));

            pnBotoes.setLayout(null);
            // ---- adicionar ----
            adicionar.setText(GERAL.BTN_ADICIONAR);
            adicionar.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    adicionarActionPerformed(e);
                }
            });

            adicionar.setToolTipText(LabelPanel.BTN_ADICIONAR_TOOLTIP);
            adicionar.getAccessibleContext().setAccessibleDescription(LabelPanel.BTN_ADICIONAR_TOOLTIP);
            adicionar.getAccessibleContext().setAccessibleName(LabelPanel.BTN_ADICIONAR_TOOLTIP);
            adicionar.setBounds(10, 5, 150, 25);
            pnBotoes.add(adicionar);

            // ---- aplicarRotulo ----
            aplicarRotulo.setEnabled(false);
            aplicarRotulo.setText(LabelPanel.BTN_APLICAR_ROTULO);
            aplicarRotulo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    aplicarRotuloActionPerformed(e);
                }
            });

            aplicarRotulo.setToolTipText(LabelPanel.BTN_APLICAR_ROTULO_TOOLTIP);
            aplicarRotulo.getAccessibleContext()
                    .setAccessibleDescription(LabelPanel.BTN_APLICAR_ROTULO_TOOLTIP);
            aplicarRotulo.getAccessibleContext().setAccessibleName(LabelPanel.BTN_APLICAR_ROTULO_TOOLTIP);
            aplicarRotulo.setBounds(165, 5, 150, 25);
            pnBotoes.add(aplicarRotulo);
        }
    }
    /*
     * Colocar os controles
     */
    pnRegra.setBackground(CoresDefault.getCorPaineis());
    regraFonteBtn.add(pnRegra, BorderLayout.NORTH);
    textAreaSourceCode.setBorder(criaBorda(""));
    textAreaSourceCode.setBackground(CoresDefault.getCorPaineis());
    regraFonteBtn.add(textAreaSourceCode, BorderLayout.CENTER);
    pnBotoes.setPreferredSize(new Dimension(600, 35));
    pnBotoes.setBackground(CoresDefault.getCorPaineis());
    regraFonteBtn.add(pnBotoes, BorderLayout.SOUTH);
    regraFonteBtn.setBackground(CoresDefault.getCorPaineis());
    contentPane.add(regraFonteBtn);

    JPanel textoErrosBtn = new JPanel();
    textoErrosBtn.setLayout(new BorderLayout());
    pnParticRotulo.setBackground(CoresDefault.getCorPaineis());
    textoErrosBtn.add(pnParticRotulo, BorderLayout.NORTH);
    textoErrosBtn.add(pnListaErros, BorderLayout.CENTER);
    JPanel pnSalvarCancelar = new JPanel();
    pnSalvarCancelar.setLayout(null);
    pnSalvarCancelar.setPreferredSize(new Dimension(600, 35));
    pnSalvarCancelar.add(salvar);
    pnSalvarCancelar.add(abrir);
    pnSalvarCancelar.add(cancelar);
    pnSalvarCancelar.setBackground(CoresDefault.getCorPaineis());
    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());
                parentFrame.showPainelFerramentaLabelPArq(TxtBuffer.getContentOriginal());
                setVisible(true);
            }
        });
        //reverter.setActionCommand("Reverter");
        reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER);
        reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER);
        reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER);
        reverter.setBounds(485, 0, 150, 25);
        pnSalvarCancelar.add(reverter);
    }

    textoErrosBtn.add(pnSalvarCancelar, BorderLayout.SOUTH);
    pnListaErros.setBackground(CoresDefault.getCorPaineis());
    if (tableLinCod.getRowCount() == 0)
        tableLinCod.addLinha(0, 0, GERAL.DOC_SEM_ERROS);
    textoErrosBtn.add(pnListaErros, BorderLayout.CENTER);
    contentPane.setBackground(CoresDefault.getCorPaineis());
    contentPane.add(textoErrosBtn);

    this.setVisible(true);

}

From source file:jmemorize.gui.swing.frames.MainFrame.java

private void initComponents() {
    final JPanel mainPanel = new JPanel(new BorderLayout());

    m_deckChartPanel = new DeckChartPanel(this);
    m_deckChartPanel.setMinimumSize(new Dimension(100, 150));

    m_learnPanel = new LearnPanel();
    m_deckTablePanel = new DeckTablePanel(this);

    // north panel
    final JPanel northPanel = new JPanel();
    northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS));
    northPanel.add(buildOperationsBar());
    northPanel.add(buildCategoryBar());//from   ww  w  . j a va2s.c  o m

    m_categoryTree = new CategoryTree(jMemorizeIO);
    m_categoryTree.addSelectionObserver(new SelectionObserver() {

        @Override
        public void selectionChanged(final SelectionProvider source) {
            treeSelectionChanged(source);
        }

    });
    m_treeScrollPane = new JScrollPane(m_categoryTree);

    // bottom panel
    m_bottomPanel = new JPanel(new CardLayout());
    m_bottomPanel.add(m_deckTablePanel, DECK_CARD);
    m_bottomPanel.add(m_learnPanel, REPEAT_CARD);

    // vertical split pane
    m_verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    m_verticalSplitPane.setPreferredSize(new Dimension(16, 500));
    m_verticalSplitPane.setBorder(null);
    beautifyDividerBorder(m_verticalSplitPane);

    m_verticalSplitPane.setTopComponent(m_deckChartPanel);
    m_verticalSplitPane.setBottomComponent(m_bottomPanel);

    mainPanel.setPreferredSize(new Dimension(800, 500));
    mainPanel.add(m_verticalSplitPane, BorderLayout.CENTER);

    // horizontal split pane
    m_horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    m_horizontalSplitPane.setDividerLocation(m_categoryTreeWidth);
    m_horizontalSplitPane.setDividerSize(DIVIDER_SIZE);
    m_horizontalSplitPane.setBorder(null);

    m_horizontalSplitPane.setLeftComponent(m_treeScrollPane);
    m_horizontalSplitPane.setRightComponent(mainPanel);

    // frame content pane
    getContentPane().add(northPanel, BorderLayout.NORTH);
    getContentPane().add(m_horizontalSplitPane, BorderLayout.CENTER);
    getContentPane().add(m_statusBar, BorderLayout.SOUTH);
    setJMenuBar(new MainMenu(this, m_main.getRecentLessonFiles(), jMemorizeIO, this));

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent evt) {
            ExitAction.exit();
        }
    });

    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/resource/icons/main.png"))); //$NON-NLS-1$
    pack();
}

From source file:org.jfree.chart.demo.PlotOrientationDemo.java

/**
 * Creates a new demo instance./*from  ww  w  .j  a v  a  2 s . c  o  m*/
 * 
 * @param title  the frame title.
 */
public PlotOrientationDemo(String title) {

    super(title);
    JPanel panel = new JPanel(new GridLayout(2, 4));
    for (int i = 0; i < CHART_COUNT; i++) {
        this.datasets[i] = createDataset(i);
        this.charts[i] = createChart(i, this.datasets[i]);
        XYPlot plot = this.charts[i].getXYPlot();
        XYShapeAnnotation a1 = new XYShapeAnnotation(new Rectangle2D.Double(1.0, 2.0, 2.0, 3.0),
                new BasicStroke(1.0f), Color.blue);
        XYLineAnnotation a2 = new XYLineAnnotation(0.0, -5.0, 10.0, -5.0);
        XYImageAnnotation a3 = new XYImageAnnotation(5.0, 2.0, JFreeChart.INFO.getLogo());
        plot.addAnnotation(a1);
        plot.addAnnotation(a2);
        plot.addAnnotation(a3);
        plot.setQuadrantPaint(0, new Color(230, 230, 255));
        plot.setQuadrantPaint(1, new Color(230, 255, 230));
        plot.setQuadrantPaint(2, new Color(255, 230, 230));
        plot.setQuadrantPaint(3, new Color(255, 230, 255));
        this.panels[i] = new ChartPanel(this.charts[i]);
    }
    this.charts[1].getXYPlot().getDomainAxis().setInverted(true);
    this.charts[2].getXYPlot().getRangeAxis().setInverted(true);
    this.charts[3].getXYPlot().getDomainAxis().setInverted(true);
    this.charts[3].getXYPlot().getRangeAxis().setInverted(true);

    this.charts[5].getXYPlot().getDomainAxis().setInverted(true);
    this.charts[6].getXYPlot().getRangeAxis().setInverted(true);
    this.charts[4].getXYPlot().getDomainAxis().setInverted(true);
    this.charts[4].getXYPlot().getRangeAxis().setInverted(true);

    this.charts[4].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);
    this.charts[5].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);
    this.charts[6].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);
    this.charts[7].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);

    panel.add(this.panels[0]);
    panel.add(this.panels[1]);
    panel.add(this.panels[4]);
    panel.add(this.panels[5]);
    panel.add(this.panels[2]);
    panel.add(this.panels[3]);
    panel.add(this.panels[6]);
    panel.add(this.panels[7]);

    panel.setPreferredSize(new Dimension(800, 600));
    setContentPane(panel);

}

From source file:Clavis.Windows.WShedule.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from w w w .j  a v  a 2  s  .c  o m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jPanelInicial = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new org.jdesktop.swingx.JXTable();
    ;
    jButtonSair = new javax.swing.JButton();
    jXDatePickerInicio = new org.jdesktop.swingx.JXDatePicker();
    jXDatePickerFim = new org.jdesktop.swingx.JXDatePicker();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jButtonImprimir = new javax.swing.JButton();
    jComboBoxEstado = new javax.swing.JComboBox<>();
    jLabel3 = new javax.swing.JLabel();
    jButtonExportar = new javax.swing.JButton();

    setMinimumSize(new java.awt.Dimension(900, 600));
    setSize(new java.awt.Dimension(900, 600));

    jPanelInicial.setBorder(javax.swing.BorderFactory.createCompoundBorder(
            javax.swing.BorderFactory.createLineBorder(painelcor, 4),
            javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))));
    jPanelInicial.setMinimumSize(new java.awt.Dimension(900, 500));
    jPanelInicial.setPreferredSize(new java.awt.Dimension(900, 500));

    org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder1 = new org.jdesktop.swingx.border.DropShadowBorder();
    dropShadowBorder1.setCornerSize(6);
    dropShadowBorder1.setShadowSize(3);
    dropShadowBorder1.setShowLeftShadow(true);
    jScrollPane1.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder1,
            javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))));

    jTable1.setBorder(null);
    if (mat.getTypeOfMaterial().getMaterialTypeID() == 1) {
        jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
                new String[] { lingua.translate("Utilizador"), lingua.translate("Horrio"),
                        lingua.translate("Data"), lingua.translate("Atividade"),
                        lingua.translate("Disciplina") }));
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(250);
        jTable1.getColumnModel().getColumn(1).setMinWidth(90);
        jTable1.getColumnModel().getColumn(2).setMinWidth(90);
        jTable1.getColumnModel().getColumn(3).setMinWidth(150);
        jTable1.getColumnModel().getColumn(4).setMinWidth(150);
    } else {
        jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
                new String[] { lingua.translate("Utilizador"), lingua.translate("Data inicial"),
                        lingua.translate("Data final"), lingua.translate("Atividade") }));
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(250);
        jTable1.getColumnModel().getColumn(1).setMinWidth(90);
        jTable1.getColumnModel().getColumn(2).setMinWidth(90);
        jTable1.getColumnModel().getColumn(3).setMinWidth(150);
    }
    jScrollPane1.setViewportView(jTable1);
    Border border = BorderFactory.createEmptyBorder(5, 5, 0, 0);
    UIManager.put("Table.focusCellHighlightBorder", border);
    jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setHorizontalAlignment(javax.swing.JLabel.CENTER);
    renderer.setFocusable(false);
    javax.swing.JLabel lo = new javax.swing.JLabel();
    lo.setBackground(new Color(100, 100, 100));
    lo.setOpaque(true);
    jScrollPane1.setCorner(javax.swing.JScrollPane.UPPER_TRAILING_CORNER, lo);
    jTable1.setRowHeight(30);
    jTable1.setEditable(false);
    jTable1.setSelectionBackground(Color.DARK_GRAY);
    jTable1.getColumnModel().getColumn(1).setCellRenderer(renderer);
    jTable1.getColumnModel().getColumn(2).setCellRenderer(renderer);
    jTable1.getColumnModel().getColumn(3).setCellRenderer(renderer);
    if (mat.getTypeOfMaterial().getMaterialTypeID() == 1) {
        jTable1.getColumnModel().getColumn(4).setCellRenderer(renderer);
    }
    DefaultTableCellRenderer headerRenderer = new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 2L;

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setFont(new Font("Cantarell", Font.PLAIN, 14));
            this.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 0, new Color(1, 1, 1)));
            return this;
        }
    };
    DefaultTableCellRenderer headerRenderer2 = new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 3L;

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setFont(new Font("Cantarell", Font.PLAIN, 14));
            this.setBorder(BorderFactory.createCompoundBorder(
                    BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(1, 1, 1)),
                    BorderFactory.createEmptyBorder(0, 20, 0, 0)));
            this.setBackground(new Color(100, 100, 100));
            setForeground(Color.WHITE);
            setPreferredSize(new Dimension(100, 40));
            return this;
        }
    };

    headerRenderer.setBackground(new Color(100, 100, 100));
    headerRenderer.setForeground(Color.WHITE);
    headerRenderer.setPreferredSize(new Dimension(100, 40));
    headerRenderer.setHorizontalAlignment(javax.swing.JLabel.CENTER);
    for (int i = 0; i < jTable1.getColumnCount(); i++) {
        if (i == 0) {
            headerRenderer2.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer2);
        } else {
            jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer);
        }
    }

    jButtonSair.setBackground(new java.awt.Color(1, 1, 1));
    jButtonSair.setToolTipText("");
    jButtonSair.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jButtonSair.setFocusPainted(false);
    jButtonSair.setMaximumSize(new java.awt.Dimension(90, 40));
    jButtonSair.setMinimumSize(new java.awt.Dimension(90, 40));
    jButtonSair.setPreferredSize(new java.awt.Dimension(90, 40));
    jButtonSair.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonSairActionPerformed(evt);
        }
    });

    jXDatePickerInicio.setBackground(new java.awt.Color(254, 254, 254));
    org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder2 = new org.jdesktop.swingx.border.DropShadowBorder();
    dropShadowBorder2.setCornerSize(6);
    dropShadowBorder2.setShadowSize(3);
    dropShadowBorder2.setShowLeftShadow(true);
    jXDatePickerInicio.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder2,
            javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, new java.awt.Color(0, 0, 0))));
    jXDatePickerInicio.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jXDatePickerInicio.setMaximumSize(new java.awt.Dimension(1155551, 26));
    jXDatePickerInicio.setMinimumSize(new java.awt.Dimension(66, 26));
    jXDatePickerInicio.setPreferredSize(new java.awt.Dimension(131, 26));
    jXDatePickerInicio.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jXDatePickerInicioActionPerformed(evt);
        }
    });

    jXDatePickerFim.setBackground(new java.awt.Color(254, 254, 254));
    org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder3 = new org.jdesktop.swingx.border.DropShadowBorder();
    dropShadowBorder3.setCornerSize(6);
    dropShadowBorder3.setShadowSize(3);
    dropShadowBorder3.setShowLeftShadow(true);
    jXDatePickerFim.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder3,
            javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, new java.awt.Color(0, 0, 0))));
    jXDatePickerFim.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jXDatePickerFim.setMaximumSize(new java.awt.Dimension(1155551, 26));
    jXDatePickerFim.setMinimumSize(new java.awt.Dimension(66, 26));
    jXDatePickerFim.setPreferredSize(new java.awt.Dimension(121, 26));

    jLabel1.setBackground(new java.awt.Color(100, 100, 100));
    jLabel1.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(254, 254, 254));
    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText("Incio");
    jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
    jLabel1.setMaximumSize(new java.awt.Dimension(3343446, 96));
    jLabel1.setMinimumSize(new java.awt.Dimension(36, 26));
    jLabel1.setOpaque(true);
    jLabel1.setPreferredSize(new java.awt.Dimension(100, 20));

    jLabel2.setBackground(new java.awt.Color(100, 100, 100));
    jLabel2.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jLabel2.setForeground(new java.awt.Color(254, 254, 254));
    jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel2.setText("Fim");
    jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabel2.setMaximumSize(new java.awt.Dimension(355557, 96));
    jLabel2.setMinimumSize(new java.awt.Dimension(37, 26));
    jLabel2.setOpaque(true);
    jLabel2.setPreferredSize(new java.awt.Dimension(100, 20));

    jButtonImprimir.setBackground(new java.awt.Color(51, 102, 153));
    jButtonImprimir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jButtonImprimir.setFocusPainted(false);
    jButtonImprimir.setMaximumSize(new java.awt.Dimension(5345, 40));
    jButtonImprimir.setPreferredSize(new java.awt.Dimension(90, 40));
    jButtonImprimir.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonImprimirActionPerformed(evt);
        }
    });

    jComboBoxEstado.setBackground(new java.awt.Color(213, 213, 213));
    jComboBoxEstado.setBorder(null);
    jComboBoxEstado.setFocusable(false);
    jComboBoxEstado.setMinimumSize(new java.awt.Dimension(35, 22));
    jComboBoxEstado.setPreferredSize(new java.awt.Dimension(125, 28));
    jComboBoxEstado.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jComboBoxEstadoActionPerformed(evt);
        }
    });

    jLabel3.setBackground(new java.awt.Color(100, 100, 100));
    jLabel3.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jLabel3.setForeground(new java.awt.Color(254, 254, 254));
    jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel3.setText("Estado");
    jLabel3.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jLabel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabel3.setMaximumSize(new java.awt.Dimension(355557, 96));
    jLabel3.setMinimumSize(new java.awt.Dimension(37, 26));
    jLabel3.setOpaque(true);
    jLabel3.setPreferredSize(new java.awt.Dimension(100, 20));

    jButtonExportar.setBackground(new java.awt.Color(51, 102, 153));
    jButtonExportar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jButtonExportar.setFocusPainted(false);
    jButtonExportar.setMaximumSize(new java.awt.Dimension(5345, 40));
    jButtonExportar.setPreferredSize(new java.awt.Dimension(90, 40));
    jButtonExportar.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonExportarActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanelInicialLayout = new javax.swing.GroupLayout(jPanelInicial);
    jPanelInicial.setLayout(jPanelInicialLayout);
    jPanelInicialLayout.setHorizontalGroup(jPanelInicialLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(42, 42, 42)
                    .addGroup(jPanelInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelInicialLayout.createSequentialGroup().addComponent(jScrollPane1)
                                    .addGap(42, 42, 42))
                            .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(29, 29, 29)
                                    .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButtonExportar, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(71, 71, 71))))
            .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(71, 71, 71)
                    .addGroup(jPanelInicialLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jXDatePickerInicio, javax.swing.GroupLayout.DEFAULT_SIZE, 152,
                                    Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanelInicialLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                            .addComponent(jXDatePickerFim, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 201, Short.MAX_VALUE)
                    .addGroup(jPanelInicialLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jComboBoxEstado, 0, 241, Short.MAX_VALUE))
                    .addGap(71, 71, 71)));
    jPanelInicialLayout
            .setVerticalGroup(jPanelInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(16, 16, 16)
                            .addGroup(jPanelInicialLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(0, 0, 0)
                            .addGroup(jPanelInicialLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jXDatePickerInicio, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jXDatePickerFim, javax.swing.GroupLayout.PREFERRED_SIZE, 31,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jComboBoxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 465,
                                    Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanelInicialLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButtonExportar, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(16, 16, 16)));

    try {
        if (Clavis.KeyQuest.class.getResource("Images/exit26x24.png") != null) {
            BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/exit26x24.png"));
            ImageIcon imic = new ImageIcon(im);
            if (imic != null) {
                jButtonSair.setIcon(imic);
            }
        }
    } catch (IOException eo) {
    }

    jButtonSair.setToolTipText(lingua.translate("Voltar"));
    javax.swing.JPanel pan2 = new javax.swing.JPanel(null);
    String compoe = lingua.translate("Hoje  dia") + ": " + new TimeDate.Date().toString();
    javax.swing.JLabel fil2 = new javax.swing.JLabel(compoe);
    fil2.setBounds(0, 0, 300, 26);
    fil2.setHorizontalAlignment(SwingConstants.CENTER);
    pan2.setPreferredSize(new Dimension(300, 30));
    pan2.setBounds(0, 0, 300, 30);
    pan2.add(fil2);
    jXDatePickerInicio.setLinkPanel(pan2);

    jXDatePickerInicio.setLocale(lingua.systemlocale);
    jXDatePickerInicio.getEditor().setSelectionColor(Color.DARK_GRAY);
    jXDatePickerInicio.getEditor().setBorder(BorderFactory.createEmptyBorder());
    jXDatePickerInicio.getEditor().setHorizontalAlignment(SwingConstants.CENTER);
    javax.swing.JButton bbt2 = (javax.swing.JButton) jXDatePickerInicio.getComponent(1);
    bbt2.setBackground(Color.WHITE);

    jXDatePickerInicio.addActionListener(actionJXDatePicker());
    jXDatePickerInicio.setFormats("dd/MM/yyyy");
    javax.swing.JPanel pan = new javax.swing.JPanel(null);
    String compoe0 = lingua.translate("Hoje  dia") + ": " + new TimeDate.Date().toString();
    javax.swing.JLabel fil = new javax.swing.JLabel(compoe);
    fil.setBounds(0, 0, 300, 26);
    fil.setHorizontalAlignment(SwingConstants.CENTER);
    pan.setPreferredSize(new Dimension(300, 30));
    pan.setBounds(0, 0, 300, 30);
    pan.add(fil);
    jXDatePickerFim.setLinkPanel(pan);

    Component[] t = jXDatePickerFim.getLinkPanel().getComponents();

    jXDatePickerFim.setLocale(lingua.systemlocale);
    jXDatePickerFim.getEditor().setSelectionColor(Color.DARK_GRAY);
    jXDatePickerFim.getEditor().setBorder(BorderFactory.createEmptyBorder());
    jXDatePickerFim.getEditor().setHorizontalAlignment(SwingConstants.CENTER);
    javax.swing.JButton bbt = (javax.swing.JButton) jXDatePickerFim.getComponent(1);
    bbt.setBackground(Color.WHITE);
    jXDatePickerFim.addActionListener(actionJXDatePicker());
    jXDatePickerFim.setFormats("dd/MM/yyyy");
    jLabel1.setText(lingua.translate("Incio"));
    jLabel2.setText(lingua.translate("Fim"));
    try {
        if (Clavis.KeyQuest.class.getResource("Images/print.png") != null) {
            BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/print.png"));
            ImageIcon imic = new ImageIcon(im);
            if (imic != null) {
                jButtonImprimir.setIcon(imic);
            }
        }
    } catch (IOException eo) {
    }

    jButtonImprimir.setToolTipText(lingua.translate("Imprimir"));
    jComboBoxEstado.setModel(new javax.swing.DefaultComboBoxModel<>(
            new String[] { lingua.translate("todos"), lingua.translate("terminado"),
                    lingua.translate("no realizado"), lingua.translate("por realizar") }));
    Clavis.KeyQuest.addVisualComboBox(jComboBoxEstado);
    ((javax.swing.JLabel) jComboBoxEstado.getRenderer()).setHorizontalAlignment(javax.swing.JLabel.CENTER);
    jLabel3.setText(lingua.translate("Estado"));
    try {
        if (Clavis.KeyQuest.class.getResource("Images/exportar.png") != null) {
            BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/exportar.png"));
            ImageIcon imic = new ImageIcon(im);
            if (imic != null) {
                jButtonExportar.setIcon(imic);
            }
        }
    } catch (IOException eo) {
    }

    jButtonExportar.setToolTipText(lingua.translate("Exportar para excel"));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addComponent(jPanelInicial,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(0, 0, 0)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE));
}

From source file:me.childintime.childintime.ui.window.tool.BmiToolDialog.java

/**
 * Build the UI student panel.//from w w w. j a v  a 2  s .  c om
 *
 * @return Student panel.
 */
private JPanel buildUiStudentPanel() {
    // Create a grid bag constraints configuration
    GridBagConstraints c = new GridBagConstraints();

    // Create a panel for the student selector
    final JPanel studentPanel = new JPanel(new GridBagLayout());

    // Create a group filter property field
    this.groupFilterField = new EntityPropertyField(Core.getInstance().getGroupManager(), true);
    this.groupFilterField.setNull(true);

    // Add the student label
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(0, 2, 2, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    studentPanel.add(new JLabel("Student group filter:"), c);

    // Add the group filter
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.insets = new Insets(0, 0, 8, 0);
    c.anchor = GridBagConstraints.CENTER;
    studentPanel.add(this.groupFilterField, c);

    // Create a student selector list
    this.studentList = new EntityListSelectorComponent(Core.getInstance().getStudentManager());

    // Create a listener to set the student list filter when the group changes
    this.groupFilterField.addValueChangeListenerListener(newValue -> {
        // Set or clear the filter
        if (newValue != null)
            this.studentList.setFilter(StudentFields.GROUP_ID, newValue);
        else
            this.studentList.clearFilter();
    });

    // Add the student label
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(8, 2, 2, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    studentPanel.add(new JLabel("Student:"), c);

    // Add the student list
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 1;
    c.weighty = 1;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    studentPanel.add(this.studentList, c);

    // Set the minimum preferred size
    studentPanel.setPreferredSize(new Dimension(200, 200));

    // Return the student panel
    return studentPanel;
}

From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java

/**
 * Build content for animationType StatisticGrafic.ANIMATION_TimeValueDiagram
 * @return//from ww  w  .j  av a 2  s .  co m
 * @throws ModelException
 */
private JPanel buildTimeValueDiagramPanel() throws ModelException {
    JPanel out = null;
    XYPlot plot = null;
    switch (this.statistic.getTypeData()) {
    case Statistic.DATA_Observations:
        XYSeriesCollection dataset1 = new XYSeriesCollection();
        dataset1.addSeries(this.statistic.getObservationSerie());
        this.chart = ChartFactory.createScatterPlot(null, "Time", null, dataset1, PlotOrientation.VERTICAL,
                false, true, false);
        this.chart.setBackgroundPaint(Grafic.COLOR_BACKGROUND);
        plot = this.chart.getXYPlot();
        break;
    case Statistic.DATA_TimeSeries:
        TimeSeriesCollection dataset2 = new TimeSeriesCollection();
        dataset2.addSeries(this.statistic.getTimeSerie());
        this.chart = ChartFactory.createXYStepChart(null, "Time", null, dataset2, PlotOrientation.VERTICAL,
                false, true, false);
        this.chart.setBackgroundPaint(Grafic.COLOR_BACKGROUND);
        plot = this.chart.getXYPlot();
        break;
    }
    if (plot != null) {
        plot.setBackgroundPaint(StatisticGrafic.DIAGRAM_BACKGROUND);
        plot.setDomainGridlinePaint(StatisticGrafic.DIAGRAM_GRID);
        plot.setRangeGridlinePaint(StatisticGrafic.DIAGRAM_GRID);
        plot.setDomainCrosshairVisible(true);
        plot.setRangeCrosshairVisible(true);
        String rangeAxisLabel = "";
        switch (statistic.getTypeIndex()) {
        case Statistic.INDEX_Min_Max:
            rangeAxisLabel = "min - max";
            break;
        case Statistic.INDEX_Mean_StdDev:
            rangeAxisLabel = "\u03BC-\u03C3 - mean - \u03BC+\u03C3";
            break;
        }
        //this.buildTimeValueDiagramAxisFormat(plot, rangeAxisLabel);
        plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f));
        plot.getRenderer().setSeriesPaint(0, StatisticGrafic.DIAGRAM_FORGROUND);

    }
    out = new ChartPanel(chart);
    out.setPreferredSize(new Dimension(350, 200));
    return out;
}

From source file:io.github.jeremgamer.editor.panels.components.PanelsPanel.java

public PanelsPanel(JFrame frame, final PanelSave ps) {
    this.ps = ps;
    this.frame = frame;
    this.setSize(new Dimension(395, frame.getHeight() - 27 - 23));
    this.setLocation(300, 0);
    this.setBorder(BorderFactory.createTitledBorder("Edition du panneau"));

    JPanel content = new JPanel();
    JScrollPane scroll = new JScrollPane(content);
    scroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    scroll.setBorder(null);//  ww w . ja va 2s  . c om
    content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS));
    scroll.setPreferredSize(new Dimension(382, frame.getHeight() - 27 - 46 - 20));

    JPanel namePanel = new JPanel();
    name.setPreferredSize(new Dimension(this.getWidth() - 280, 30));
    name.setEditable(false);
    namePanel.add(new JLabel("Nom :"));
    namePanel.add(name);
    namePanel.add(Box.createRigidArea(new Dimension(10, 1)));
    layout.addItem("Basique");
    layout.addItem("Bordures");
    layout.addItem("Ligne");
    layout.addItem("Colonne");
    layout.addItem("Grille");
    layout.addItem("Empil");
    layout.setPreferredSize(new Dimension(110, 30));
    layout.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) event.getSource();
            cl.show(advanced, listContent[combo.getSelectedIndex()]);
            ps.set("layout", combo.getSelectedIndex());
            ActionPanel.updateLists();
        }

    });
    namePanel.add(new JLabel("Disposition :"));
    namePanel.add(layout);
    namePanel.setPreferredSize(new Dimension(365, 50));
    namePanel.setMaximumSize(new Dimension(365, 50));
    content.add(namePanel);

    advanced.setPreferredSize(new Dimension(365, 300));
    advanced.setMaximumSize(new Dimension(365, 300));
    advanced.add(ble, listContent[0]);
    advanced.add(brdle, listContent[1]);
    advanced.add(lle, listContent[2]);
    advanced.add(rle, listContent[3]);
    advanced.add(gle, listContent[4]);
    advanced.add(cle, listContent[5]);

    content.add(advanced);

    topBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) event.getSource();
            ps.set("border.top", combo.getSelectedItem());
        }

    });
    leftBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) event.getSource();
            ps.set("border.left", combo.getSelectedItem());
        }

    });
    centerBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) event.getSource();
            ps.set("border.center", combo.getSelectedItem());
        }

    });
    rightBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) event.getSource();
            ps.set("border.right", combo.getSelectedItem());
        }

    });
    bottomBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) event.getSource();
            ps.set("border.bottom", combo.getSelectedItem());
        }

    });

    JPanel prefSize = new JPanel();
    prefSize.setPreferredSize(new Dimension(365, 110));
    prefSize.setMaximumSize(new Dimension(365, 110));
    prefSize.setBorder(BorderFactory.createTitledBorder("Taille prfre"));
    JPanel prefSizePanel = new JPanel();
    prefSizePanel.setLayout(new GridLayout(2, 4));
    prefSizePanel.setPreferredSize(new Dimension(300, 55));
    prefSizePanel.setMaximumSize(new Dimension(300, 55));
    prefSizePanel.add(prefSizeEnabled);
    prefSizePanel.add(new JLabel(""));
    prefSizePanel.add(new JLabel(""));
    prefSizePanel.add(new JLabel("(en pixels)"));
    prefSizePanel.add(new JLabel("Largeur :"));
    prefSizePanel.add(prefWidth);
    prefSizePanel.add(new JLabel("Hauteur :"));
    prefSizePanel.add(prefHeight);
    prefWidth.setEnabled(false);
    prefHeight.setEnabled(false);
    prefSizeEnabled.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            JCheckBox check = (JCheckBox) event.getSource();
            ps.set("preferredSize", check.isSelected());
            prefWidth.setEnabled(check.isSelected());
            prefHeight.setEnabled(check.isSelected());
        }
    });
    prefWidth.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent event) {
            JSpinner spinner = (JSpinner) event.getSource();
            ps.set("preferredWidth", spinner.getValue());
        }
    });
    prefHeight.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent event) {
            JSpinner spinner = (JSpinner) event.getSource();
            ps.set("preferredHeight", spinner.getValue());
        }
    });
    prefSize.add(prefSizePanel);

    content.add(prefSize);

    JPanel insetsPanel = new JPanel();
    insetsPanel.setBorder(BorderFactory.createTitledBorder("carts"));
    insetsPanel.setPreferredSize(new Dimension(365, 100));
    insetsPanel.setMaximumSize(new Dimension(365, 100));

    JPanel insetsContent = new JPanel();
    insetsContent.setLayout(new BoxLayout(insetsContent, BoxLayout.PAGE_AXIS));

    JPanel insetInput = new JPanel();
    insetInput.setLayout(new GridLayout(2, 4));
    insetInput.add(insetsEnabled);
    insetInput.add(new JLabel(""));
    insetInput.add(new JLabel(""));
    insetInput.add(new JLabel("(en pixels)"));
    insetInput.add(new JLabel("Horizontaux :"));
    insetInput.add(insetHz);
    insetInput.add(new JLabel("Verticaux :"));
    insetInput.add(insetVt);

    insetsEnabled.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            JCheckBox check = (JCheckBox) event.getSource();
            if (check.isSelected()) {
                insetHz.setEnabled(true);
                insetVt.setEnabled(true);
                ps.set("insets", true);
            } else {
                insetHz.setEnabled(true);
                insetVt.setEnabled(true);
                ps.set("insets", false);
            }
        }

    });

    insetHz.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent event) {
            JSpinner spinner = (JSpinner) event.getSource();
            ps.set("insets.horizontal", spinner.getValue());
        }
    });
    insetVt.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent event) {
            JSpinner spinner = (JSpinner) event.getSource();
            ps.set("insets.vertical", spinner.getValue());
        }
    });

    insetsContent.add(insetInput);
    insetsPanel.add(insetsContent);

    content.add(insetsPanel);

    JPanel web = new JPanel();
    web.setPreferredSize(new Dimension(365, 100));
    web.setMaximumSize(new Dimension(365, 100));
    web.setBorder(BorderFactory.createTitledBorder("Page Web"));

    JPanel webContent = new JPanel();
    webContent.setLayout(new BorderLayout());
    webContent.add(webEnabled, BorderLayout.NORTH);
    webEnabled.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JCheckBox check = (JCheckBox) e.getSource();
            ps.set("web", check.isSelected());
            if (check.isSelected() == true) {
                layout.setSelectedIndex(0);
                layout.setEnabled(false);
                ble.removeAllComponents();
                ble.disableComponents();
                adress.setEnabled(true);
            } else {
                ble.enableComponents();
                layout.setEnabled(true);
                adress.setEnabled(false);
            }
        }
    });
    JPanel webInput = new JPanel();
    webInput.add(new JLabel("Adresse :"));
    adress.setPreferredSize(new Dimension(250, 30));
    CaretListener caretUpdate = new CaretListener() {
        public void caretUpdate(javax.swing.event.CaretEvent e) {
            JTextField text = (JTextField) e.getSource();
            ps.set("web.adress", text.getText());
        }
    };
    adress.addCaretListener(caretUpdate);
    webInput.add(adress);
    webContent.add(webInput, BorderLayout.CENTER);

    web.add(webContent);

    JPanel background = new JPanel();
    BorderLayout bLayout = new BorderLayout();
    bLayout.setVgap(12);
    background.setLayout(bLayout);
    background.setBorder(BorderFactory.createTitledBorder("Couleur de fond"));
    background.setPreferredSize(new Dimension(365, 210));
    background.setMaximumSize(new Dimension(365, 210));
    cp.setPreferredSize(new Dimension(347, 145));
    cp.setMaximumSize(new Dimension(347, 145));
    opaque.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JCheckBox check = (JCheckBox) e.getSource();
            ps.set("background.opaque", check.isSelected());
            cp.enableComponents(check.isSelected());
        }
    });
    background.add(opaque, BorderLayout.NORTH);
    background.add(cp, BorderLayout.CENTER);

    JPanel image = new JPanel();
    image.setBorder(BorderFactory.createTitledBorder("Image de fond"));
    image.setPreferredSize(new Dimension(365, 125));
    image.setMaximumSize(new Dimension(365, 125));
    image.setLayout(new BorderLayout());
    try {
        remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    remove.setEnabled(false);
    remove.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            File img = new File(
                    "projects/" + Editor.getProjectName() + "/panels/" + name.getText() + "/background.png");
            if (img.exists()) {
                img.delete();
            }
            browseImage.setEnabled(true);
        }

    });
    JPanel top = new JPanel();
    browseImage.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JButton button = (JButton) e.getSource();
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "background.png");
                nameBackground.setText(new File(path).getName());
                ps.set("background.image", new File(path).getName());
                button.setEnabled(false);
                size.setEnabled(true);
                size2.setEnabled(true);
                remove.setEnabled(true);
            }
        }

    });
    bg.add(size);
    bg.add(size2);
    JPanel sizePanel = new JPanel();
    sizePanel.setLayout(new BoxLayout(sizePanel, BoxLayout.PAGE_AXIS));
    size.setEnabled(false);
    size2.setEnabled(false);
    sizePanel.add(size);
    sizePanel.add(size2);
    size.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            ps.set("background.size", 0);
        }

    });
    size2.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            ps.set("background.size", 1);
        }

    });
    top.add(browseImage);
    top.add(sizePanel);

    remove.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            JButton button = (JButton) event.getSource();
            new File("projects/" + Editor.getProjectName() + "/panels/" + name.getText() + "/background.png")
                    .delete();
            nameBackground.setText("");
            ps.set("background.image", "");
            button.setEnabled(false);
        }

    });
    nameBackground.setFont(new Font("Sans Serif", Font.PLAIN, 15));
    JPanel center = new JPanel(new BorderLayout());
    center.add(nameBackground, BorderLayout.CENTER);
    center.add(remove, BorderLayout.EAST);

    image.add(top, BorderLayout.NORTH);
    image.add(center, BorderLayout.CENTER);

    content.add(web);
    content.add(background);
    content.add(image);

    this.add(scroll);
}

From source file:AppearanceExplorer.java

public Color3fEditor(String initName, Color3f initColor) {
    name = initName;//from   ww w  .  ja v  a 2 s. c  om
    color.set(initColor);

    JLabel label = new JLabel(name);

    preview = new JPanel();
    preview.setPreferredSize(new Dimension(40, 40));
    preview.setBackground(color.get());
    preview.setBorder(BorderFactory.createRaisedBevelBorder());

    button = new JButton("Set");
    button.addActionListener(this);

    JPanel filler = new JPanel();
    filler.setPreferredSize(new Dimension(100, 20));

    setLayout(new BorderLayout());
    Box box = new Box(BoxLayout.X_AXIS);
    add(box, BorderLayout.WEST);

    box.add(label);
    box.add(preview);
    box.add(button);
    box.add(filler);

}