Example usage for javax.swing JLabel setOpaque

List of usage examples for javax.swing JLabel setOpaque

Introduction

In this page you can find the example usage for javax.swing JLabel setOpaque.

Prototype

@BeanProperty(expert = true, description = "The component's opacity")
public void setOpaque(boolean isOpaque) 

Source Link

Document

If true the component paints every pixel within its bounds.

Usage

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   ww w. j  a va2s  .  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:org.forester.archaeopteryx.ControlPanel.java

/**
 * Add zoom and quick edit buttons. (Last modified 8/9/04)
 *//*from w ww.j  av  a 2 s .  co  m*/
void addButtons() {
    final JLabel spacer = new JLabel("");
    spacer.setOpaque(false);
    add(spacer);
    final JPanel x_panel = new JPanel(new GridLayout(1, 1, 0, 0));
    final JPanel y_panel = new JPanel(new GridLayout(1, 3, 0, 0));
    final JPanel z_panel = new JPanel(new GridLayout(1, 1, 0, 0));
    if (!getConfiguration().isUseNativeUI()) {
        x_panel.setBackground(getBackground());
        y_panel.setBackground(getBackground());
        z_panel.setBackground(getBackground());
    }
    add(_zoom_label = new JLabel("Zoom:"));
    customizeLabel(_zoom_label, getConfiguration());
    add(x_panel);
    add(y_panel);
    add(z_panel);
    if (getConfiguration().isUseNativeUI()) {
        _zoom_in_x = new JButton("+");
        _zoom_out_x = new JButton("-");
    } else {
        _zoom_in_x = new JButton("X+");
        _zoom_out_x = new JButton("X-");
    }
    _zoom_in_y = new JButton("Y+");
    _zoom_out_y = new JButton("Y-");
    _show_whole = new JButton("F");
    _show_whole.setToolTipText("To fit the complete phylogeny to the current display size [Backspace]");
    _zoom_in_x.setToolTipText("To zoom in horizontally [Shift+Right]");
    _zoom_in_y.setToolTipText("To zoom in vertically [Shift+Up]");
    _zoom_out_x.setToolTipText("To zoom out horizontally [Shift+Left]");
    _zoom_out_y.setToolTipText("To zoom out vertically [Shift+Down]");
    if (getConfiguration().isUseNativeUI() && Util.isMac()) {
        _zoom_out_x.setPreferredSize(new Dimension(55, 10));
        _zoom_in_x.setPreferredSize(new Dimension(55, 10));
    } else {
        _zoom_out_x.setPreferredSize(new Dimension(10, 10));
        _zoom_in_x.setPreferredSize(new Dimension(10, 10));
    }
    _zoom_out_y.setPreferredSize(new Dimension(10, 10));
    _zoom_in_y.setPreferredSize(new Dimension(10, 10));
    _show_whole.setPreferredSize(new Dimension(10, 10));
    _return_to_super_tree = new JButton(RETURN_TO_SUPER_TREE_TEXT);
    _return_to_super_tree.setEnabled(false);
    _order = new JButton("Order Subtrees");
    _uncollapse_all = new JButton("Uncollapse All");
    addJButton(_zoom_in_y, x_panel);
    addJButton(_zoom_out_x, y_panel);
    addJButton(_show_whole, y_panel);
    addJButton(_zoom_in_x, y_panel);
    addJButton(_zoom_out_y, z_panel);
    //        if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
    //            setUpControlsForDomainStrucures();
    //        }
    final JLabel spacer2 = new JLabel("");
    add(spacer2);
    addJButton(_return_to_super_tree, this);
    addJButton(_order, this);
    addJButton(_uncollapse_all, this);
    final JLabel spacer3 = new JLabel("");
    add(spacer3);
    setVisibilityOfDomainStrucureControls();
}

From source file:filterviewplugin.FilterViewSettingsTab.java

public JPanel createSettingsPanel() {
    final EnhancedPanelBuilder panelBuilder = new EnhancedPanelBuilder(FormFactory.RELATED_GAP_COLSPEC.encode()
            + ',' + FormFactory.PREF_COLSPEC.encode() + ',' + FormFactory.RELATED_GAP_COLSPEC.encode() + ','
            + FormFactory.PREF_COLSPEC.encode() + ", fill:default:grow");
    final CellConstraints cc = new CellConstraints();

    final JLabel label = new JLabel(mLocalizer.msg("daysToShow", "Days to show"));

    panelBuilder.addRow();/* w ww  .j  a  v a  2s .  co  m*/
    panelBuilder.add(label, cc.xy(2, panelBuilder.getRow()));

    final SpinnerNumberModel model = new SpinnerNumberModel(3, 1, 7, 1);
    mSpinner = new JSpinner(model);
    mSpinner.setValue(mSettings.getDays());
    panelBuilder.add(mSpinner, cc.xy(4, panelBuilder.getRow()));

    panelBuilder.addParagraph(mLocalizer.msg("filters", "Filters to show"));

    mFilterList = new SelectableItemList(mSettings.getActiveFilterNames(),
            FilterViewSettings.getAvailableFilterNames());
    mIcons.clear();
    for (String filterName : FilterViewSettings.getAvailableFilterNames()) {
        mIcons.put(filterName, mSettings.getFilterIconName(mSettings.getFilter(filterName)));
    }
    mFilterList.addCenterRendererComponent(String.class, new SelectableItemRendererCenterComponentIf() {
        private DefaultListCellRenderer mRenderer = new DefaultListCellRenderer();

        public void calculateSize(JList list, int index, JPanel contentPane) {
        }

        public JPanel createCenterPanel(JList list, Object value, int index, boolean isSelected,
                boolean isEnabled, JScrollPane parentScrollPane, int leftColumnWidth) {
            DefaultListCellRenderer label = (DefaultListCellRenderer) mRenderer
                    .getListCellRendererComponent(list, value, index, isSelected, false);
            String filterName = value.toString();
            String iconFileName = mIcons.get(filterName);
            Icon icon = null;
            if (!StringUtils.isEmpty(iconFileName)) {
                try {
                    icon = FilterViewPlugin.getInstance().getIcon(
                            FilterViewSettings.getIconDirectoryName() + File.separatorChar + iconFileName);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                label.setIcon(icon);
            }
            String text = filterName;
            if (icon == null) {
                text += " (" + mLocalizer.msg("noIcon", "no icon") + ')';
            }
            label.setText(text);
            label.setHorizontalAlignment(SwingConstants.LEADING);
            label.setVerticalAlignment(SwingConstants.CENTER);
            label.setOpaque(false);

            JPanel panel = new JPanel(new BorderLayout());
            if (isSelected && isEnabled) {
                panel.setOpaque(true);
                panel.setForeground(list.getSelectionForeground());
                panel.setBackground(list.getSelectionBackground());
            } else {
                panel.setOpaque(false);
                panel.setForeground(list.getForeground());
                panel.setBackground(list.getBackground());
            }
            panel.add(label, BorderLayout.WEST);
            return panel;
        }
    });

    panelBuilder.addGrowingRow();
    panelBuilder.add(mFilterList, cc.xyw(2, panelBuilder.getRow(), panelBuilder.getColumnCount() - 1));

    panelBuilder.addRow();
    mFilterButton = new JButton(mLocalizer.msg("changeIcon", "Change icon"));
    mFilterButton.setEnabled(false);
    panelBuilder.add(mFilterButton, cc.xyw(2, panelBuilder.getRow(), 1));

    mRemoveButton = new JButton(mLocalizer.msg("deleteIcon", "Remove icon"));
    mRemoveButton.setEnabled(false);
    panelBuilder.add(mRemoveButton, cc.xyw(4, panelBuilder.getRow(), 1));

    mFilterButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SelectableItem item = (SelectableItem) mFilterList.getSelectedValue();
            String filterName = (String) item.getItem();
            chooseIcon(filterName);
        }
    });

    mFilterList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            mFilterButton.setEnabled(mFilterList.getSelectedValue() != null);
            mRemoveButton.setEnabled(mFilterButton.isEnabled());
        }
    });

    mRemoveButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SelectableItem item = (SelectableItem) mFilterList.getSelectedValue();
            String filterName = (String) item.getItem();
            mIcons.put(filterName, "");
            mFilterList.updateUI();
        }
    });

    return panelBuilder.getPanel();
}

From source file:fs.MainWindow.java

public void GenerateTable(Object[][] data, String title, String subtitle, final String[] titles) {
    JFrame window = new JFrame(title);
    window.setLayout(new java.awt.BorderLayout(5, 5));
    JLabel label = new JLabel(subtitle);
    label.setFont(new java.awt.Font("Tahoma", 1, 12));
    label.setForeground(new java.awt.Color(0, 0, 255));
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setOpaque(true);
    label.setPreferredSize(new java.awt.Dimension(50, 30));

    ListModel lm = new AbstractListModel() {

        String headers[] = titles;

        @Override/* ww w .  j a  v a 2 s.  com*/
        public int getSize() {
            return headers.length;
        }

        @Override
        public Object getElementAt(int index) {
            return headers[index];
        }
    };

    //        String[] titles = getClasses();
    JList rowHeader = new JList(lm);
    rowHeader.setFixedCellWidth(50);
    JTable jTable = new JTable(data, titles);
    rowHeader.setFixedCellHeight(jTable.getRowHeight());
    rowHeader.setCellRenderer(new RowHeaderRenderer(jTable));
    JScrollPane scroll = new JScrollPane(jTable);
    scroll.setRowHeaderView(rowHeader);
    getContentPane().add(scroll, BorderLayout.CENTER);

    jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    jTable.setAlignmentX(JTable.CENTER_ALIGNMENT);

    window.add(label, java.awt.BorderLayout.NORTH);
    window.add(scroll, java.awt.BorderLayout.CENTER);

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    window.setBounds((screenSize.width - 800) / 2, (screenSize.height - 270) / 2, 800, 270);
    window.setVisible(true);
}

From source file:web.diva.server.model.SomClustering.SomClustImgGenerator.java

public void drawTable(Graphics gr, Point UL, Dataset dataset, int[] selection, Graphics navgGr,
        int countNavUnit) {

    Font f = getTableFont(squareL - 1);
    AnnotationManager annManager = AnnotationManager.getAnnotationManager();
    String[] rowIds = dataset.getRowIds();

    Set<String> annotations = dataset.getRowAnnotationNamesInUse();
    if (annotations == null) {
        annotations = annManager.getManagedRowAnnotationNames();
    }//from  w  ww  .java 2s.  co  m

    String[][] inf; // row annotation matrix
    String[] headers; // header of the row annotation matrix
    if (annotations.isEmpty()) {
        inf = new String[dataset.getDataLength()][1];
        for (int i = 0; i < inf.length; i++) {
            inf[i][0] = rowIds[i];
        }
        headers = new String[] { "Row ID" };
    } else {
        headers = annotations.toArray(new String[annotations.size()]);
        inf = new String[dataset.getDataLength()][annotations.size()];
        for (int i = 0; i < headers.length; i++) {
            //ann manager need to re implemeinted?
            AnnotationLibrary anns = annManager.getRowAnnotations(headers[i]);
            for (int j = 0; j < inf.length; j++) {
                inf[j][i] = rowIds[j];//anns.getAnnotation(rowIds[j]);//
            }
        }
    }

    Graphics2D g2d = (Graphics2D) gr;
    Graphics2D g2dNav = (Graphics2D) navgGr;
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g2dNav.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    int X = UL.x;
    int Y = UL.y;
    //        int H = squareL;

    int L = dataset.getDataLength();
    int W = headers.length;

    JLabel l = new JLabel("    ");
    JLabel lNav = new JLabel(" ");
    //        l.setFont(f);
    //        l.setIconTextGap(2);
    javax.swing.border.Border UB = javax.swing.BorderFactory.createMatteBorder(0, 0, 0, 0, Color.WHITE);
    javax.swing.border.Border LB = javax.swing.BorderFactory.createMatteBorder(0, 0, 0, 0, Color.WHITE);

    //          Color borderColor = hex2Rgb("#e3e3e3");
    javax.swing.border.Border navBorder = javax.swing.BorderFactory.createMatteBorder(2, 0, 0, 0, Color.WHITE);

    l.setMaximumSize(new Dimension(200, squareL));
    lNav.setSize(new Dimension(2, 5));
    lNav.setBorder(navBorder);

    boolean drawTableHeader = false;

    //if there is not enough room for a header.. skip header.
    //        if (UL.y < squareL) {
    //            drawTableHeader = false;
    //        }

    if (Wd == null) {
        Wd = new int[inf[0].length];
        WdSUM = new int[inf[0].length];

        if (drawTableHeader) {
            for (int i = 0; i < headers.length; i++) {
                l.setText(headers[i]);
                l.validate();
                if (l.getPreferredSize().width > Wd[i]) {
                    Wd[i] = l.getPreferredSize().width + 16;
                }
            }
        }
        for (String[] inf1 : inf) {
            for (int j = 0; j < Wd.length; j++) {
                if (squareL < 6) {
                    Wd[j] = 5;
                    continue;
                }
                l.setText(inf1[j]);
                l.validate();
                if (l.getPreferredSize().width > Wd[j]) {
                    Wd[j] = l.getPreferredSize().width + 16;
                }
            }
        }

        WdSUM[0] = 0;

        for (int i = 0; i < Wd.length; i++) {
            WdSUM[i] = -1;
            for (int j = 0; j < i; j++) {
                WdSUM[i] += Wd[j] + 3;
            }
        }
    }

    Rectangle BNDS = new Rectangle();

    l.setBackground(Color.WHITE);
    l.setOpaque(true);

    lNav.setBackground(Color.WHITE);
    lNav.setOpaque(true);

    if (sideTree == null) {
        return;
    }

    f = getTableFont(squareL - 1);
    l.setFont(f);

    int[] LArr = sideTree.arrangement;
    int Rindex = 0;

    //draw the table header.. (if wanted)
    //        if (drawTableHeader) {
    //
    //            l.setBackground(Color.WHITE);
    //            l.setForeground(Color.white);
    //
    //            for (int j = 0; j < W; j++) {
    //                X = UL.x + WdSUM[j];
    //                Y = UL.y;
    //                BNDS.setBounds(X, Y, Wd[j], squareL + 1);
    //
    //                if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) {
    //                    continue;
    //                }
    //                gr.translate(X, Y);
    //                l.setBounds(0, 0, Wd[j] + 1, squareL + 1);
    //                l.setBorder(LB);
    //
    //                if (squareL >= 6) {
    //                    l.setText(headers[j]);
    //                }
    //                l.validate();
    //                l.paint(gr);
    //                gr.translate(-X, -Y);
    //            }
    //        }
    l.setForeground(Color.WHITE);

    boolean[] sel = selectedRows((selection == null ? null : selection), dataset);
    boolean coloredNav = false;
    int navCounter = 0;
    for (int i = 0; i < L; i++) {

        Rindex = LArr[i];
        for (int j = 0; j < W; j++) {
            X = UL.x + WdSUM[j];
            Y = UL.y + (squareL * (i + 1));

            BNDS.setBounds(X, Y, Wd[j], squareL + 1);

            if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) {
                continue;
            }

            if (sel[LArr[i]]) {

                for (Group group : dataset.getRowGroups()) {
                    if (group.isActive()) {
                        if (group.hasMember(Rindex)) {
                            l.setBackground(group.getColor());
                            if (!coloredNav) {
                                lNav.setBackground(Color.RED);
                                lNav.setForeground(Color.RED);
                                coloredNav = true;
                            }

                            break;

                        }
                    }

                }

                //                    l.setBackground(new Color(225, 225, 255));
            } else {
                //                   
                //                    if (!coloredNav) {
                //                                    lNav.setBackground(Color.WHITE);
                //                                    lNav.setForeground(Color.WHITE);                                  
                //                                }

                l.setBackground(Color.WHITE);
            }
            if (i != 0)
                gr.translate(X, Y);
            l.setBounds(0, 0, Wd[j] + 1, squareL + 1);

            if (i < L - 1) {
                l.setBorder(UB);
            } else {
                l.setBounds(0, 0, Wd[j] + 1, squareL + 1);
                l.setBorder(LB);
            }
            if (squareL >= 6) {
                l.setText(inf[Rindex][j]);
            }
            l.validate();
            l.paint(gr);
            gr.translate(-X, -Y);

        }
        if (navCounter >= countNavUnit) {
            navCounter = 0;
            lNav.validate();
            lNav.paint(navgGr);
            navgGr.translate(2, 0);
            coloredNav = false;
            lNav.setBackground(Color.WHITE);
            lNav.setForeground(Color.WHITE);

        }
        navCounter++;
    }

    //        if (squareL < 6) {
    //            return;
    //        }
    //
    //        l.setBackground(Color.WHITE);
    //        f = getTableFont(squareL - 2);
    //        //f = new Font("Arial",1,squareL-2);
    //        l.setFont(f);
    //
    //
    //        for (int j = 0; j < W; j++) {
    //            X = UL.x + WdSUM[j];
    //            Y = UL.y;
    //
    //            BNDS.setBounds(X, Y, Wd[j], squareL + 1);
    //            if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) {
    //                continue;
    //            }
    //
    //            gr.translate(X, Y);
    //            l.setBounds(0, 0, Wd[j], squareL + 1);
    ////            l.setBorder(javax.swing.BorderFactory.createLineBorder(GridCol));
    //            l.setText(headers[j]);
    //            l.validate();
    //            gr.translate(-X, -Y);
    //        }

}

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openChipOptionsDialog(final int chip) {

    // ------------------------ Disassembly options

    JPanel disassemblyOptionsPanel = new JPanel(new MigLayout("", "[left,grow][left,grow]"));

    // Prepare sample code area
    final RSyntaxTextArea listingArea = new RSyntaxTextArea(20, 90);
    SourceCodeFrame.prepareAreaFormat(chip, listingArea);

    final List<JCheckBox> outputOptionsCheckBoxes = new ArrayList<JCheckBox>();
    ActionListener areaRefresherListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Set<OutputOption> sampleOptions = EnumSet.noneOf(OutputOption.class);
                dumpOptionCheckboxes(outputOptionsCheckBoxes, sampleOptions);
                int baseAddress = framework.getPlatform(chip).getCpuState().getResetAddress();
                int lastAddress = baseAddress;
                Memory sampleMemory = new DebuggableMemory(false);
                sampleMemory.map(baseAddress, 0x100, true, true, true);
                StringWriter writer = new StringWriter();
                Disassembler disassembler;
                if (chip == Constants.CHIP_FR) {
                    sampleMemory.store16(lastAddress, 0x1781); // PUSH    RP
                    lastAddress += 2;/* ww  w.  j  av a2s.c o  m*/
                    sampleMemory.store16(lastAddress, 0x8FFE); // PUSH    (FP,AC,R12,R11,R10,R9,R8)
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x83EF); // ANDCCR  #0xEF
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x9F80); // LDI:32  #0x68000000,R0
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x6800);
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x0000);
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x2031); // LD      @(FP,0x00C),R1
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0xB581); // LSL     #24,R1
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x1A40); // DMOVB   R13,@0x40
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x9310); // ORCCR   #0x10
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x8D7F); // POP     (R8,R9,R10,R11,R12,AC,FP)
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x0781); // POP    RP
                    lastAddress += 2;

                    disassembler = new Dfr();
                    disassembler.setDebugPrintWriter(new PrintWriter(new StringWriter())); // Ignore
                    disassembler.setOutputFileName(null);
                    disassembler.processOptions(new String[] { "-m", "0x" + Format.asHex(baseAddress, 8) + "-0x"
                            + Format.asHex(lastAddress, 8) + "=CODE" });
                } else {
                    sampleMemory.store32(lastAddress, 0x340B0001); // li      $t3, 0x0001
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x17600006); // bnez    $k1, 0xBFC00020
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x00000000); //  nop
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x54400006); // bnezl   $t4, 0xBFC00028
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x3C0C0000); //  ?lui   $t4, 0x0000
                    lastAddress += 4;

                    int baseAddress16 = lastAddress;
                    int lastAddress16 = baseAddress16;
                    sampleMemory.store32(lastAddress16, 0xF70064F6); // save    $ra,$s0,$s1,$s2-$s7,$fp, 0x30
                    lastAddress16 += 4;
                    sampleMemory.store16(lastAddress16, 0x6500); // nop
                    lastAddress16 += 2;
                    sampleMemory.store32(lastAddress16, 0xF7006476); // restore $ra,$s0,$s1,$s2-$s7,$fp, 0x30
                    lastAddress16 += 4;
                    sampleMemory.store16(lastAddress16, 0xE8A0); // ret
                    lastAddress16 += 2;

                    disassembler = new Dtx();
                    disassembler.setDebugPrintWriter(new PrintWriter(new StringWriter())); // Ignore
                    disassembler.setOutputFileName(null);
                    disassembler.processOptions(new String[] { "-m",
                            "0x" + Format.asHex(baseAddress, 8) + "-0x" + Format.asHex(lastAddress, 8)
                                    + "=CODE:32",
                            "-m", "0x" + Format.asHex(baseAddress16, 8) + "-0x" + Format.asHex(lastAddress16, 8)
                                    + "=CODE:16" });
                }
                disassembler.setOutputOptions(sampleOptions);
                disassembler.setMemory(sampleMemory);
                disassembler.initialize();
                disassembler.setOutWriter(writer);
                disassembler.disassembleMemRanges();
                disassembler.cleanup();
                listingArea.setText("");
                listingArea.append(writer.toString());
                listingArea.setCaretPosition(0);

            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    };

    int i = 1;
    for (OutputOption outputOption : OutputOption.allFormatOptions) {
        JCheckBox checkBox = makeOutputOptionCheckBox(chip, outputOption, prefs.getOutputOptions(chip), false);
        if (checkBox != null) {
            outputOptionsCheckBoxes.add(checkBox);
            disassemblyOptionsPanel.add(checkBox, (i % 2 == 0) ? "wrap" : "");
            checkBox.addActionListener(areaRefresherListener);
            i++;
        }
    }
    if (i % 2 == 0) {
        disassemblyOptionsPanel.add(new JLabel(), "wrap");
    }

    // Force a refresh
    areaRefresherListener.actionPerformed(new ActionEvent(outputOptionsCheckBoxes.get(0), 0, ""));

    //        disassemblyOptionsPanel.add(new JLabel("Sample output:", SwingConstants.LEADING), "gapbottom 1, span, split 2, aligny center");
    //        disassemblyOptionsPanel.add(new JSeparator(), "span 2,wrap");
    disassemblyOptionsPanel.add(new JSeparator(), "span 2, gapleft rel, growx, wrap");
    disassemblyOptionsPanel.add(new JLabel("Sample output:"), "span 2,wrap");
    disassemblyOptionsPanel.add(new JScrollPane(listingArea), "span 2,wrap");
    disassemblyOptionsPanel.add(new JLabel("Tip: hover over the option checkboxes for help"),
            "span 2, center, wrap");

    // ------------------------ Emulation options

    JPanel emulationOptionsPanel = new JPanel(new VerticalLayout(5, VerticalLayout.LEFT));
    emulationOptionsPanel.add(new JLabel());
    JLabel warningLabel = new JLabel(
            "NOTE: these options only take effect after reloading the firmware (or performing a 'Stop and reset')");
    warningLabel.setBackground(Color.RED);
    warningLabel.setOpaque(true);
    warningLabel.setForeground(Color.WHITE);
    warningLabel.setHorizontalAlignment(SwingConstants.CENTER);
    emulationOptionsPanel.add(warningLabel);
    emulationOptionsPanel.add(new JLabel());

    final JCheckBox writeProtectFirmwareCheckBox = new JCheckBox("Write-protect firmware");
    writeProtectFirmwareCheckBox.setSelected(prefs.isFirmwareWriteProtected(chip));
    emulationOptionsPanel.add(writeProtectFirmwareCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, any attempt to write to the loaded firmware area will result in an Emulator error. This can help trap spurious writes"));

    final JCheckBox dmaSynchronousCheckBox = new JCheckBox("Make DMA synchronous");
    dmaSynchronousCheckBox.setSelected(prefs.isDmaSynchronous(chip));
    emulationOptionsPanel.add(dmaSynchronousCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, DMA operations will be performed immediately, pausing the CPU. Otherwise they are performed in a separate thread."));

    final JCheckBox autoEnableTimersCheckBox = new JCheckBox("Auto enable timers");
    autoEnableTimersCheckBox.setSelected(prefs.isAutoEnableTimers(chip));
    emulationOptionsPanel.add(autoEnableTimersCheckBox);
    emulationOptionsPanel
            .add(new JLabel("If checked, timers will be automatically enabled upon reset or firmware load."));

    // Log memory messages
    final JCheckBox logMemoryMessagesCheckBox = new JCheckBox("Log memory messages");
    logMemoryMessagesCheckBox.setSelected(prefs.isLogMemoryMessages(chip));
    emulationOptionsPanel.add(logMemoryMessagesCheckBox);
    emulationOptionsPanel
            .add(new JLabel("If checked, messages related to memory will be logged to the console."));

    // Log serial messages
    final JCheckBox logSerialMessagesCheckBox = new JCheckBox("Log serial messages");
    logSerialMessagesCheckBox.setSelected(prefs.isLogSerialMessages(chip));
    emulationOptionsPanel.add(logSerialMessagesCheckBox);
    emulationOptionsPanel.add(
            new JLabel("If checked, messages related to serial interfaces will be logged to the console."));

    // Log register messages
    final JCheckBox logRegisterMessagesCheckBox = new JCheckBox("Log register messages");
    logRegisterMessagesCheckBox.setSelected(prefs.isLogRegisterMessages(chip));
    emulationOptionsPanel.add(logRegisterMessagesCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, warnings related to unimplemented register addresses will be logged to the console."));

    // Log pin messages
    final JCheckBox logPinMessagesCheckBox = new JCheckBox("Log pin messages");
    logPinMessagesCheckBox.setSelected(prefs.isLogPinMessages(chip));
    emulationOptionsPanel.add(logPinMessagesCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, warnings related to unimplemented I/O pins will be logged to the console."));

    emulationOptionsPanel.add(new JSeparator(JSeparator.HORIZONTAL));

    // Alt mode upon Debug
    JPanel altDebugPanel = new JPanel(new FlowLayout());
    Object[] altDebugMode = EnumSet.allOf(EmulationFramework.ExecutionMode.class).toArray();
    final JComboBox altModeForDebugCombo = new JComboBox(new DefaultComboBoxModel(altDebugMode));
    for (int j = 0; j < altDebugMode.length; j++) {
        if (altDebugMode[j].equals(prefs.getAltExecutionModeForSyncedCpuUponDebug(chip))) {
            altModeForDebugCombo.setSelectedIndex(j);
        }
    }
    altDebugPanel.add(new JLabel(Constants.CHIP_LABEL[1 - chip] + " mode when " + Constants.CHIP_LABEL[chip]
            + " runs in sync Debug: "));
    altDebugPanel.add(altModeForDebugCombo);
    emulationOptionsPanel.add(altDebugPanel);
    emulationOptionsPanel
            .add(new JLabel("If 'sync mode' is selected, this is the mode the " + Constants.CHIP_LABEL[1 - chip]
                    + " chip will run in when running the " + Constants.CHIP_LABEL[chip] + " in Debug mode"));

    // Alt mode upon Step
    JPanel altStepPanel = new JPanel(new FlowLayout());
    Object[] altStepMode = EnumSet.allOf(EmulationFramework.ExecutionMode.class).toArray();
    final JComboBox altModeForStepCombo = new JComboBox(new DefaultComboBoxModel(altStepMode));
    for (int j = 0; j < altStepMode.length; j++) {
        if (altStepMode[j].equals(prefs.getAltExecutionModeForSyncedCpuUponStep(chip))) {
            altModeForStepCombo.setSelectedIndex(j);
        }
    }
    altStepPanel.add(new JLabel(Constants.CHIP_LABEL[1 - chip] + " mode when " + Constants.CHIP_LABEL[chip]
            + " runs in sync Step: "));
    altStepPanel.add(altModeForStepCombo);
    emulationOptionsPanel.add(altStepPanel);
    emulationOptionsPanel
            .add(new JLabel("If 'sync mode' is selected, this is the mode the " + Constants.CHIP_LABEL[1 - chip]
                    + " chip will run in when running the " + Constants.CHIP_LABEL[chip] + " in Step mode"));

    // ------------------------ Prepare tabbed pane

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " Disassembly Options", null, disassemblyOptionsPanel);
    tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " Emulation Options", null, emulationOptionsPanel);

    if (chip == Constants.CHIP_TX) {
        JPanel chipSpecificOptionsPanel = new JPanel(new VerticalLayout(5, VerticalLayout.LEFT));

        chipSpecificOptionsPanel.add(new JLabel("Eeprom status upon startup:"));

        ActionListener eepromInitializationRadioActionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                prefs.setEepromInitMode(Prefs.EepromInitMode.valueOf(e.getActionCommand()));
            }
        };
        JRadioButton blank = new JRadioButton("Blank");
        blank.setActionCommand(Prefs.EepromInitMode.BLANK.name());
        blank.addActionListener(eepromInitializationRadioActionListener);
        if (Prefs.EepromInitMode.BLANK.equals(prefs.getEepromInitMode()))
            blank.setSelected(true);
        JRadioButton persistent = new JRadioButton("Persistent across sessions");
        persistent.setActionCommand(Prefs.EepromInitMode.PERSISTENT.name());
        persistent.addActionListener(eepromInitializationRadioActionListener);
        if (Prefs.EepromInitMode.PERSISTENT.equals(prefs.getEepromInitMode()))
            persistent.setSelected(true);
        JRadioButton lastLoaded = new JRadioButton("Last Loaded");
        lastLoaded.setActionCommand(Prefs.EepromInitMode.LAST_LOADED.name());
        lastLoaded.addActionListener(eepromInitializationRadioActionListener);
        if (Prefs.EepromInitMode.LAST_LOADED.equals(prefs.getEepromInitMode()))
            lastLoaded.setSelected(true);

        ButtonGroup group = new ButtonGroup();
        group.add(blank);
        group.add(persistent);
        group.add(lastLoaded);

        chipSpecificOptionsPanel.add(blank);
        chipSpecificOptionsPanel.add(persistent);
        chipSpecificOptionsPanel.add(lastLoaded);

        chipSpecificOptionsPanel.add(new JLabel("Front panel type:"));
        final JComboBox frontPanelNameCombo = new JComboBox(new String[] { "D5100_small", "D5100_large" });
        if (prefs.getFrontPanelName() != null) {
            frontPanelNameCombo.setSelectedItem(prefs.getFrontPanelName());
        }
        frontPanelNameCombo.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                prefs.setFrontPanelName((String) frontPanelNameCombo.getSelectedItem());
            }
        });
        chipSpecificOptionsPanel.add(frontPanelNameCombo);

        emulationOptionsPanel.add(new JSeparator(JSeparator.HORIZONTAL));

        tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " specific options", null, chipSpecificOptionsPanel);
    }

    // ------------------------ Show it

    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, tabbedPane,
            Constants.CHIP_LABEL[chip] + " options", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
            null, null, JOptionPane.DEFAULT_OPTION)) {
        // save output options
        dumpOptionCheckboxes(outputOptionsCheckBoxes, prefs.getOutputOptions(chip));
        // apply
        TxCPUState.initRegisterLabels(prefs.getOutputOptions(chip));

        // save other prefs
        prefs.setFirmwareWriteProtected(chip, writeProtectFirmwareCheckBox.isSelected());
        prefs.setDmaSynchronous(chip, dmaSynchronousCheckBox.isSelected());
        prefs.setAutoEnableTimers(chip, autoEnableTimersCheckBox.isSelected());
        prefs.setLogRegisterMessages(chip, logRegisterMessagesCheckBox.isSelected());
        prefs.setLogSerialMessages(chip, logSerialMessagesCheckBox.isSelected());
        prefs.setLogPinMessages(chip, logPinMessagesCheckBox.isSelected());
        prefs.setLogMemoryMessages(chip, logMemoryMessagesCheckBox.isSelected());
        prefs.setAltExecutionModeForSyncedCpuUponDebug(chip,
                (EmulationFramework.ExecutionMode) altModeForDebugCombo.getSelectedItem());
        prefs.setAltExecutionModeForSyncedCpuUponStep(chip,
                (EmulationFramework.ExecutionMode) altModeForStepCombo.getSelectedItem());

    }
}

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_//from  w  w  w . j ava2 s  . com
 *
 * @param g _more_
 * @param comp _more_
 */
public void paintDashboardAfter(Graphics g, JComponent comp) {

    Graphics2D g2 = (Graphics2D) g;
    AffineTransform oldTransform = g2.getTransform();
    Rectangle b = dashboardLbl.getBounds();
    int w = dashboardImage.getWidth(null);
    int h = dashboardImage.getHeight(null);
    Point ul = new Point(b.width / 2 - w / 2, b.height - h);
    int ptsIdx = 0;

    try {
        pipPanel.setPreferredSize(new Dimension(dialPts[ptsIdx][2], dialPts[ptsIdx][3]));
        pipFrame.setSize(dialPts[ptsIdx][2], dialPts[ptsIdx][3]);
        pipPanel.doLayout();
        pipPanel.validate();
        pipFrame.pack();
        pipPanel.resetDrawBounds();
        pipPanel.redraw();
    } catch (Exception ignore) {
    }

    JLabel locLbl = null;

    if (lastLocation != null) {
        try {
            locLbl = new JLabel("<html><table width=100%><tr><td align=right>&nbsp;Lat:</td></td>"
                    + getIdv().getDisplayConventions().formatLatLon(getLat(lastLocation)) + "</td></tr>"
                    + "<tr><td align=right>&nbsp;Lon:</td></td>"
                    + getIdv().getDisplayConventions().formatLatLon(getLon(lastLocation)) + "</td></tr>"
                    + "<tr><td align=right>&nbsp;Alt:</td></td>"
                    + getIdv().getDisplayConventions().formatDistance(getAlt(lastLocation)) + "</table>");
        } catch (Exception ignore) {
        }
    }
    if (locLbl == null) {
        locLbl = new JLabel(
                "<html><table width=100%><tr><td align=right>&nbsp;Lat:</td></td>N/A </td></tr><tr><td align=right>&nbsp;Lon:</td></td>N/A </td></tr><tr><td align=right>&nbsp;Alt:</td></td>N/A </table>");
    }
    locLbl.setOpaque(true);
    locLbl.setBackground(Color.white);

    DefaultValueDataset headingDataset = new DefaultValueDataset(new Double(currentHeading));

    CompassPlot plot = new CompassPlot(headingDataset);
    plot.setSeriesNeedle(0);
    plot.setSeriesPaint(0, Color.red);
    plot.setSeriesOutlinePaint(0, Color.red);
    JFreeChart chart = new JFreeChart("", plot);
    ChartPanel compassPanel = new ChartPanel(chart);

    plot.setBackgroundPaint(new Color(255, 255, 255, 0));
    plot.setBackgroundImageAlpha(0.0f);
    chart.setBackgroundPaint(new Color(255, 255, 255, 0));
    compassPanel.setBackground(new Color(255, 255, 255, 0));
    compassPanel.setPreferredSize(dialDimension);
    //        compassPanel.setSize(new Dimension(100,100));

    g2.setTransform(oldTransform);
    pipRect = drawDial(g2, pipPanel, ptsIdx++, ul);

    JFrame dummyFrame = new JFrame("");
    dummyFrame.setContentPane(compassPanel);
    dummyFrame.pack();

    g2.setTransform(oldTransform);
    drawDial(g2, compassPanel, ptsIdx++, ul);

    g2.setTransform(oldTransform);
    dummyFrame.setContentPane(locLbl);
    dummyFrame.pack();
    drawDial(g2, locLbl, ptsIdx++, ul);

    if (showReadout) {
        for (JComponent dial : dials) {
            dummyFrame.setContentPane(dial);
            dummyFrame.pack();

            g2.setTransform(oldTransform);
            drawDial(g2, dial, ptsIdx++, ul);
        }
    }

    g2.setTransform(oldTransform);

}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java

/**
 * @param parentList//from w ww.j a v a 2  s .  c om
 */
protected void fillNextList(final JList parentList) {
    if (processingLists) {
        return;
    }

    processingLists = true;

    final int curInx = listBoxList.indexOf(parentList);
    if (curInx > -1) {
        int startSize = listBoxPanel.getComponentCount();
        for (int i = curInx + 1; i < listBoxList.size(); i++) {
            listBoxPanel.remove(spList.get(i));
        }
        int removed = startSize - listBoxPanel.getComponentCount();
        for (int i = 0; i < removed; i++) {
            tableTreeList.remove(tableTreeList.size() - 1);
        }

    } else {
        listBoxPanel.removeAll();
        tableTreeList.clear();
    }

    QryListRendererIFace item = (QryListRendererIFace) parentList.getSelectedValue();
    if (item instanceof ExpandableQRI) {
        JList newList;
        DefaultListModel model;
        JScrollPane sp;

        if (curInx == listBoxList.size() - 1) {
            newList = new JList(model = new DefaultListModel());
            newList.addMouseListener(new MouseAdapter() {

                /* (non-Javadoc)
                 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
                 */
                @Override
                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        if (currentInx != -1) {
                            JList list = (JList) e.getSource();
                            QryListRendererIFace qriFace = (QryListRendererIFace) list.getSelectedValue();
                            if (BaseQRI.class.isAssignableFrom(qriFace.getClass())) {
                                BaseQRI qri = (BaseQRI) qriFace;
                                if (qri.isInUse()) {
                                    //remove the field
                                    for (QueryFieldPanel qfp : QueryBldrPane.this.queryFieldItems) {
                                        FieldQRI fqri = qfp.getFieldQRI();
                                        if (fqri == qri || (fqri instanceof RelQRI && fqri.getTable() == qri)) {
                                            boolean clearIt = qfp.getSchemaItem() != null;
                                            QueryBldrPane.this.removeQueryFieldItem(qfp);
                                            if (clearIt) {
                                                qfp.setField(null, null);
                                            }
                                            break;
                                        }
                                    }
                                } else {
                                    // add the field
                                    try {
                                        FieldQRI fieldQRI = buildFieldQRI(qri);
                                        if (fieldQRI == null) {
                                            throw new Exception("null FieldQRI");
                                        }
                                        SpQueryField qf = new SpQueryField();
                                        qf.initialize();
                                        qf.setFieldName(fieldQRI.getFieldName());
                                        qf.setStringId(fieldQRI.getStringId());
                                        query.addReference(qf, "fields");
                                        if (!isExportMapping) {
                                            addQueryFieldItem(fieldQRI, qf, false);
                                        } else {
                                            addNewMapping(fieldQRI, qf, null, false);
                                        }
                                    } catch (Exception ex) {
                                        log.error(ex);
                                        UsageTracker.incrHandledUsageCount();
                                        edu.ku.brc.exceptions.ExceptionTracker.getInstance()
                                                .capture(QueryBldrPane.class, ex);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            });
            newList.setCellRenderer(qryRenderer);
            listBoxList.add(newList);
            sp = new JScrollPane(newList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            JLabel colHeader = UIHelper.createLabel(item.getTitle());
            colHeader.setHorizontalAlignment(SwingConstants.CENTER);
            colHeader.setBackground(listBoxPanel.getBackground());
            colHeader.setOpaque(true);

            sp.setColumnHeaderView(colHeader);

            spList.add(sp);

            newList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
                public void valueChanged(ListSelectionEvent e) {
                    if (!e.getValueIsAdjusting()) {
                        fillNextList(listBoxList.get(curInx + 1));
                    }
                }
            });

        } else {
            newList = listBoxList.get(curInx + 1);
            model = (DefaultListModel) newList.getModel();
            sp = spList.get(curInx + 1);
            JLabel colHeaderLbl = (JLabel) sp.getColumnHeader().getComponent(0);
            if (item instanceof TableQRI) {
                colHeaderLbl.setText(((TableQRI) item).getTitle());
            } else {
                colHeaderLbl.setText(getResourceString("QueryBldrPane.QueryFields"));
            }
        }

        createNewList((TableQRI) item, model);

        listBoxPanel.remove(addBtn);
        listBoxPanel.add(sp);
        tableTreeList.add(((ExpandableQRI) item).getTableTree());
        listBoxPanel.add(addBtn);
        currentInx = -1;

    } else {
        listBoxPanel.add(addBtn);
    }

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            updateAddBtnState();

            // Is all this really necessary
            listBoxPanel.validate();
            listBoxPanel.repaint();
            scrollPane.validate();
            scrollPane.invalidate();
            scrollPane.doLayout();
            scrollPane.repaint();
            validate();
            invalidate();
            doLayout();
            repaint();
            UIRegistry.forceTopFrameRepaint();
        }
    });

    processingLists = false;
    currentInx = curInx;

}

From source file:base.BasePlayer.Main.java

void setMenuBar() {
    //filemenu.addMouseListener(this);

    //toolmenu.addMouseListener(this);
    filemenu = new JMenu("File");
    toolmenu = new JMenu("Tools");
    help = new JMenu("Help");
    about = new JMenu("About");
    menubar = new JMenuBar();
    //help.addMouseListener(this);
    exit = new JMenuItem("Exit");
    manual = new JButton("Online manual");
    manual.addActionListener(new ActionListener() {

        @Override/*from  w  ww .j  ava2 s  .c  o  m*/
        public void actionPerformed(ActionEvent arg0) {
            Main.gotoURL("https://baseplayer.fi/BPmanual");
        }

    });
    //   opensamples = new JMenuItem("Add samples");
    zoomout = new JButton("Zoom out");
    back = new JButton("<<");
    forward = new JButton(">>");
    manage = new JButton("Variant Manager");
    openvcfs = new JMenuItem("Add VCFs", open);
    openbams = new JMenuItem("Add BAMs", open);
    average = new JMenuItem("Coverage calculator");
    update = new JMenuItem("Update");
    update.setVisible(false);
    errorlog = new JMenuItem("View log");
    //helpLabel = new JLabel("This is pre-release version of BasePlayer\nContact: help@baseplayer.fi\n\nUniversity of Helsinki");

    addURL = new JMenu("Add from URL");
    urlField = new JTextField("Enter URL");
    addtracks = new JMenuItem("Add tracks");
    fromURL = new JMenuItem("Add track from URL");
    addcontrols = new JMenuItem("Add controls");
    pleiadesButton = new JMenuItem("PLEIADES");
    saveProject = new JMenuItem("Save project");
    saveProjectAs = new JMenuItem("Save project as...");
    openProject = new JMenuItem("Open project");
    clear = new JMenuItem("Clear data");
    clearMemory = new JMenuItem("Clean memory");
    //   welcome = new JMenuItem("Welcome screen");
    filemenu.add(openvcfs);
    filemenu.add(openbams);
    variantCaller = new JMenuItem("Variant Caller");
    tbrowser = new JMenuItem("Table Browser");
    bconvert = new JMenuItem("BED converter");
    peakCaller = new JMenuItem("Peak Caller");
    addtracks = new JMenuItem("Add tracks", open);
    filemenu.add(addtracks);
    addcontrols = new JMenuItem("Add controls", open);
    filemenu.add(addcontrols);
    filemenu.add(fromURL);
    if (pleiades) {
        pleiadesButton.setPreferredSize(buttonDimension);
        pleiadesButton.addActionListener(this);

        filemenu.add(pleiadesButton);
    }

    filemenu.add(new JSeparator());
    openProject = new JMenuItem("Open project", open);
    filemenu.add(openProject);
    saveProject = new JMenuItem("Save project", save);
    filemenu.add(saveProject);
    saveProjectAs = new JMenuItem("Save project as...", save);
    filemenu.add(saveProjectAs);
    filemenu.add(new JSeparator());
    filemenu.add(genome);
    filemenu.add(update);
    filemenu.add(clear);
    filemenu.add(new JSeparator());
    filemenu.add(exit);
    exit.addActionListener(this);
    menubar.add(filemenu);
    manage.addActionListener(this);
    manage.addMouseListener(this);
    update.addActionListener(this);
    average.addActionListener(this);
    average.setEnabled(false);
    average.setToolTipText("No bam/cram files opened");
    tbrowser.addActionListener(this);
    bconvert.addActionListener(this);
    toolmenu.add(tbrowser);
    toolmenu.add(average);
    toolmenu.add(variantCaller);
    toolmenu.add(bconvert);
    fromURL.addMouseListener(this);
    fromURL.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            final JPopupMenu menu = new JPopupMenu();
            final JTextField area = new JTextField();
            JButton add = new JButton("Fetch");
            JLabel label = new JLabel("Paste track URL below");
            JScrollPane menuscroll = new JScrollPane();
            add.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        String urltext = area.getText().trim();
                        Boolean size = true;
                        if (urltext.contains("pleiades")) {
                            openPleiades(urltext);
                            return;
                        }
                        if (!FileRead.isTrackFile(urltext)) {
                            showError("The file format is not supported.\n"
                                    + "Supported formats: bed, bigwig, bigbed, gff, bedgraph", "Error");
                            return;

                        }
                        if (!urltext.toLowerCase().endsWith(".bw") && !urltext.toLowerCase().endsWith(".bigwig")
                                && !urltext.toLowerCase().endsWith(".bb")
                                && !urltext.toLowerCase().endsWith(".bigbed")) {
                            URL url = null;
                            try {
                                url = new URL(urltext);
                            } catch (Exception ex) {
                                menu.setVisible(false);
                                Main.showError("Please paste whole url (protocol included)", "Error");
                                return;
                            }
                            URL testurl = url;
                            HttpURLConnection huc = (HttpURLConnection) testurl.openConnection();
                            huc.setRequestMethod("HEAD");
                            int responseCode = huc.getResponseCode();

                            if (responseCode != 404) {

                                SeekableStream stream = SeekableStreamFactory.getInstance().getStreamFor(url);
                                TabixReader tabixReader = null;
                                String index = null;

                                try {
                                    if (stream.length() / (double) 1048576 >= Settings.settings
                                            .get("bigFile")) {
                                        size = false;
                                    }
                                    tabixReader = new TabixReader(urltext, urltext + ".tbi", stream);

                                    index = urltext + ".tbi";
                                    testurl = new URL(index);
                                    huc = (HttpURLConnection) testurl.openConnection();
                                    huc.setRequestMethod("HEAD");
                                    responseCode = huc.getResponseCode();

                                    if (responseCode == 404) {
                                        menu.setVisible(false);
                                        Main.showError("Index file (.tbi) not found in the URL.", "Error");

                                        return;
                                    }

                                } catch (Exception ex) {
                                    try {
                                        tabixReader = new TabixReader(urltext,
                                                urltext.substring(0, urltext.indexOf(".gz")) + ".tbi", stream);
                                        index = urltext.substring(0, urltext.indexOf(".gz")) + ".tbi";
                                    } catch (Exception exc) {
                                        menu.setVisible(false);
                                        Main.showError("Could not read tabix file.", "Error");
                                    }
                                }
                                if (tabixReader != null && index != null) {
                                    stream.close();
                                    tabixReader.close();
                                    menu.setVisible(false);
                                    FileRead filereader = new FileRead();
                                    filereader.readBED(urltext, index, size);

                                }

                            } else {
                                menu.setVisible(false);
                                Main.showError("Not a valid URL", "Error");
                            }

                        } else {
                            URL url = null;
                            try {
                                url = new URL(urltext);
                            } catch (Exception ex) {
                                Main.showError("Please paste whole url (protocol included)", "Error");
                                return;
                            }
                            final URL testurl = url;
                            HttpURLConnection huc = (HttpURLConnection) testurl.openConnection();
                            huc.setRequestMethod("HEAD");
                            int responseCode = huc.getResponseCode();

                            if (responseCode != 404) {
                                menu.setVisible(false);
                                FileRead filereader = new FileRead();

                                filereader.readBED(urltext, "nan", true);

                            } else {
                                menu.setVisible(false);
                                Main.showError("Not a valid URL", "Error");
                            }

                        }
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }

                }

            });
            area.setFont(Main.menuFont);
            //area.setText("https://baseplayer.fi/tracks/Mappability_1000Genomes_pilot_mask.bed.gz");
            menu.add(label);
            menu.add(menuscroll);
            menu.add(add);
            area.setPreferredSize(new Dimension(300, Main.defaultFontSize + 8));

            area.setCaretPosition(0);
            area.revalidate();
            menuscroll.getViewport().add(area);
            area.requestFocus();
            menu.pack();

            menu.show(frame, mouseX + 20, fromURL.getY());
        }

    });
    //toolmenu.add(peakCaller);
    variantCaller.setToolTipText("No bam/cram files opened");
    variantCaller.addActionListener(this);
    variantCaller.setEnabled(false);
    peakCaller.setEnabled(true);
    peakCaller.addActionListener(this);
    settings.addActionListener(this);
    clearMemory.addActionListener(this);
    errorlog.addActionListener(this);
    toolmenu.add(clearMemory);
    toolmenu.add(errorlog);
    toolmenu.add(new JSeparator());
    toolmenu.add(settings);
    menubar.add(toolmenu);
    menubar.add(manage);
    area = new JEditorPane();

    String infotext = "<html><h2>BasePlayer</h2>This is a version " + version
            + " of BasePlayer (<a href=https://baseplayer.fi>https://baseplayer.fi</a>)<br/> Author: Riku Katainen <br/> University of Helsinki<br/>"
            + "Tumor Genomics Group (<a href=http://research.med.helsinki.fi/gsb/aaltonen/>http://research.med.helsinki.fi/gsb/aaltonen/</a>) <br/> "
            + "Contact: help@baseplayer.fi <br/> <br/>"

            + "Supported filetype for variants is VCF and VCF.gz (index file will be created if missing)<br/> "
            + "Supported filetypes for reads are BAM and CRAM. Index files required (.bai or .crai). <br/> "
            + "Supported filetypes for additional tracks are BED(.gz), GFF.gz, BedGraph, BigWig, BigBed.<br/> (tabix index required for bgzipped files). <br/><br/> "

            + "For optimal usage, you should have vcf.gz and bam -files for each sample. <br/> "
            + "e.g. in case you have a sample named as sample1, name all files similarly and <br/>"
            + "place in the same folder:<br/>" + "sample1.vcf.gz<br/>" + "sample1.vcf.gz.tbi<br/>"
            + "sample1.bam<br/>" + "sample1.bam.bai<br/><br/>"
            + "When you open sample1.vcf.gz, sample1.bam is recognized and opened<br/>"
            + "on the same track.<br/><br/>"
            + "Instructional videos can be viewed at our <a href=https://www.youtube.com/channel/UCywq-T7W0YPzACyB4LT7Q3g> Youtube channel</a>";
    area = new JEditorPane();
    area.setEditable(false);
    area.setEditorKit(JEditorPane.createEditorKitForContentType("text/html"));
    area.setText(infotext);
    area.setFont(Main.menuFont);
    area.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
            HyperlinkEvent.EventType type = hyperlinkEvent.getEventType();
            final URL url = hyperlinkEvent.getURL();
            if (type == HyperlinkEvent.EventType.ACTIVATED) {
                Main.gotoURL(url.toString());
            }
        }
    });

    about.add(area);
    about.addMouseListener(this);
    help.add(about);
    help.add(manual);
    menubar.add(help);
    JLabel emptylab = new JLabel("  ");
    emptylab.setEnabled(false);
    emptylab.setOpaque(false);
    menubar.add(emptylab);

    chromosomeDropdown.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.lightGray));
    chromosomeDropdown.setBorder(BorderFactory.createCompoundBorder(chromosomeDropdown.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    chromlabel.setToolTipText("Current chromosome");
    chromlabel.setFocusable(false);
    chromlabel.addMouseListener(this);
    chromlabel.setBackground(Color.white);
    chromlabel.setEditable(false);
    chromlabel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, Color.lightGray));
    chromlabel.setBorder(BorderFactory.createCompoundBorder(chromlabel.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));
    menubar.add(chromlabel);
    chromosomeDropdown.setBackground(Color.white);
    chromosomeDropdown.setToolTipText("Current chromosome");
    menubar.add(chromosomeDropdown);
    JLabel empty3 = new JLabel("  ");
    empty3.setEnabled(false);
    empty3.setOpaque(false);
    menubar.add(empty3);
    menubar.add(back);
    menubar.add(searchField);
    searchField.setForeground(Color.gray);
    searchField.setBorder(BorderFactory.createCompoundBorder(searchField.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    searchField.addMouseListener(this);
    menubar.add(back);
    menubar.add(searchField);
    searchField.setForeground(Color.gray);

    back.addMouseListener(this);
    back.setToolTipText("Back");
    forward.addMouseListener(this);
    forward.setToolTipText("Forward");
    back.setEnabled(false);
    forward.setEnabled(false);

    searchField.addMouseListener(this);

    menubar.add(back);
    menubar.add(searchField);
    searchField.setForeground(Color.gray);
    back.addMouseListener(this);
    forward.addMouseListener(this);
    back.setEnabled(false);
    forward.setEnabled(false);
    forward.setMargin(new Insets(0, 2, 0, 2));
    back.setMargin(new Insets(0, 2, 0, 2));
    menubar.add(forward);
    JLabel empty4 = new JLabel("  ");
    empty4.setOpaque(false);
    empty4.setEnabled(false);
    menubar.add(empty4);
    menubar.add(zoomout);
    JLabel empty5 = new JLabel("  ");
    empty5.setEnabled(false);
    empty5.setOpaque(false);
    menubar.add(empty5);
    positionField.setEditable(false);
    positionField.setBackground(new Color(250, 250, 250));

    positionField.setMargin(new Insets(0, 2, 0, 0));
    positionField.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));
    menubar.add(positionField);
    widthLabel.setEditable(false);
    widthLabel.setBackground(new Color(250, 250, 250));
    widthLabel.setMargin(new Insets(0, 2, 0, 0));
    widthLabel.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));
    JLabel empty6 = new JLabel("  ");
    empty6.setEnabled(false);
    empty6.setOpaque(false);
    menubar.add(empty6);
    menubar.add(widthLabel);
    JLabel empty7 = new JLabel("  ");
    empty7.setOpaque(false);
    empty7.setEnabled(false);
    menubar.add(empty7);
}

From source file:net.technicpack.launcher.ui.InstallerFrame.java

private void initComponents() {
    setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
    setIconImage(resources.getImage("icon.png"));
    setLayout(new BorderLayout());

    JPanel header = new JPanel();
    header.setBackground(Color.black);
    header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS));
    header.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8));
    add(header, BorderLayout.PAGE_START);

    JLabel title = new JLabel(resources.getString("launcher.installer.title"));
    title.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 34));
    title.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    title.setOpaque(false);
    title.setIcon(resources.getIcon("options_cog.png"));
    header.add(title);/*from   www. j av  a2 s  .c o m*/

    header.add(Box.createHorizontalGlue());

    JButton closeButton = new JButton();
    closeButton.setIcon(resources.getIcon("close.png"));
    closeButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    closeButton.setContentAreaFilled(false);
    closeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    closeButton.setFocusPainted(false);
    closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            mainFrame.setVisible(true);
            dispose();
        }
    });
    header.add(closeButton);

    SimpleTabPane centerPanel = new SimpleTabPane();
    centerPanel.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    centerPanel.setForeground(LauncherFrame.COLOR_GREY_TEXT);
    centerPanel.setSelectedBackground(LauncherFrame.COLOR_BLUE);
    centerPanel.setSelectedForeground(LauncherFrame.COLOR_WHITE_TEXT);
    centerPanel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    centerPanel.setOpaque(true);
    add(centerPanel, BorderLayout.CENTER);

    JPanel standardInstallPanel = new JPanel();
    standardInstallPanel.setBackground(LauncherFrame.COLOR_CENTRAL_BACK_OPAQUE);

    setupStandardInstall(standardInstallPanel);

    JPanel portableModePanel = new JPanel();
    portableModePanel.setBackground(LauncherFrame.COLOR_CENTRAL_BACK_OPAQUE);

    setupPortableMode(portableModePanel);

    centerPanel.addTab(resources.getString("launcher.installer.standard").toUpperCase(), standardInstallPanel);
    centerPanel.addTab(resources.getString("launcher.installer.portable").toUpperCase(), portableModePanel);

    if (settings.isPortable()) {
        centerPanel.setSelectedIndex(1);
    } else
        centerPanel.setSelectedIndex(0);

    setLocationRelativeTo(null);
}