Example usage for javax.swing SwingConstants CENTER

List of usage examples for javax.swing SwingConstants CENTER

Introduction

In this page you can find the example usage for javax.swing SwingConstants CENTER.

Prototype

int CENTER

To view the source code for javax.swing SwingConstants CENTER.

Click Source Link

Document

The central position in an area.

Usage

From source file:org.o3project.optsdn.don.frame.NeFrame.java

/**
 * Create a pane that displays OMS connection information.
 * //  w ww . jav a2 s  .  c om
 * @return The pane that displays OMS connection information
 */
private JScrollPane createOmsConnectionInfoPane() {
    Object[] header = OMS_CONNECTION_INFO_COLNAME_LIST.toArray();

    String[][] rowDataList = new String[omsConnectionInfoList.size()][header.length];
    for (int i = 0; i < rowDataList.length; i++) {
        List<Port> omsConnectionInfo = omsConnectionInfoList.get(i);

        Port port = omsConnectionInfo.get(0);
        int ofPortIndex = OMS_CONNECTION_INFO_COLNAME_LIST.indexOf(OmsConnectionInfoCols.OF_PORT.getName());
        Integer openFlowPortId1 = port.getOpenFlowPortId();
        String ofPortValue1;
        if (openFlowPortId1 == null) {
            ofPortValue1 = OFPORT_NOTFOUND;
        } else {
            ofPortValue1 = String.valueOf(openFlowPortId1);
        }
        rowDataList[i][ofPortIndex] = ofPortValue1;

        Port port2 = omsConnectionInfo.get(1);
        int connectedToIndex = OMS_CONNECTION_INFO_COLNAME_LIST
                .indexOf(OmsConnectionInfoCols.CONNECTED_TO.getName());
        Integer openFlowPortId2 = port2.getOpenFlowPortId();
        String ofPortValue2;
        if (openFlowPortId2 == null) {
            ofPortValue2 = OFPORT_NOTFOUND;
        } else {
            ofPortValue2 = String.valueOf(openFlowPortId2);
        }
        rowDataList[i][connectedToIndex] = port2.getNeId() + ", " + ofPortValue2;
    }

    JTable connectedTable = new JTable(rowDataList, header);

    connectedTable.getTableHeader().setBackground(Color.WHITE);

    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setHorizontalAlignment(SwingConstants.CENTER);
    for (int i = 0; i < header.length; i++) {
        TableColumn column = connectedTable.getColumnModel().getColumn(i);
        column.setCellRenderer(renderer);
    }

    JScrollPane connectedPane = new JScrollPane();
    connectedPane.getViewport().setView(connectedTable);
    connectedPane.setPreferredSize(new Dimension(connectedPane.getPreferredSize().width, TABLE_HEIGHT));
    return connectedPane;
}

From source file:org.o3project.optsdn.don.frame.NeFrame.java

/**
 * Create a pane that displays Information Model ID list.
 * //www  . j  ava  2  s  .  c om
 * @param portList Ports
 * @return The pane that displays Information Model ID list
 */
private JScrollPane createInformationModelIdListPane(List<Port> portList) {
    Collections.sort(portList, new PortComparator());

    Object[] columnNames = INFORMATION_MODEL_ID_COLNAME_LIST.toArray();
    DefaultTableModel tableModel = new DefaultTableModel(columnNames, 0);
    for (Port port : portList) {
        Port[] column = { port, port };
        tableModel.addRow(column);
    }

    JTable informationModeldTable = new JTable(tableModel);
    informationModeldTable.getTableHeader().setBackground(Color.WHITE);

    DefaultTableCellRenderer renderer = new InformationModelIdRenderer();
    renderer.setHorizontalAlignment(SwingConstants.CENTER);
    informationModeldTable.setDefaultRenderer(Object.class, renderer);

    JScrollPane informationModelIdPane = new JScrollPane();
    informationModelIdPane.getViewport().setView(informationModeldTable);
    informationModelIdPane
            .setPreferredSize(new Dimension(informationModelIdPane.getPreferredSize().width, TABLE_HEIGHT));

    return informationModelIdPane;
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.AjouterComptePCGtoPCEFrame.java

public AjouterComptePCGtoPCEFrame() {

    super("Ajouter un compte du plan comptable gnral");
    Container f = this.getContentPane();

    // instanciation du panel et du menu click droit associ
    Vector<AbstractAction> actionClickDroitTable = new Vector<AbstractAction>();

    actionClickDroitTable.add(new AbstractAction("Ajouter au PCE") {

        public void actionPerformed(ActionEvent e) {
            ajoutCompteSelected();/*from  w  w  w  .  j  a  v a 2s  .  c  om*/
        }
    });

    this.planPanel = new PlanComptableGPanel(actionClickDroitTable);

    this.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(12, 2, 12, 2);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridwidth = 2;
    c.gridheight = 1;
    JLabel label = new JLabel("Choississez le ou les comptes  ajouter au Plan Comptable Entreprise");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    f.add(label, c);

    /*******************************************************************************************
     * * Affichage du plan comptable entreprise
     ******************************************************************************************/
    c.insets = new Insets(0, 0, 0, 0);
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.gridy++;
    f.add(this.planPanel, c);

    /*******************************************************************************************
     * * Bouton ajout / fermer
     ******************************************************************************************/
    c.insets = new Insets(2, 2, 1, 2);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.gridy++;
    c.gridx = 0;
    c.anchor = GridBagConstraints.SOUTHEAST;

    f.add(this.boutonAjout, c);

    this.boutonAjout.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            ajoutCompteSelected();

        }
    });

    c.gridx++;
    f.add(this.boutonClose, c);
    this.boutonClose.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            AjouterComptePCGtoPCEFrame.this.setVisible(false);
            AjouterComptePCGtoPCEFrame.this.dispose();
        }
    });
    /*
     * this.pack(); this.setVisible(true);
     */
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java

/**
 * Cre le panel d'un onglet associ  une classe
 * //from   w w  w . j  ava  2s .c  o  m
 * @param cc ClasseCompte la classe des comptes
 * @return JPanel le JPanel associ
 */
private JPanel initClassePanel(ClasseCompte cc) {

    final JPanel panelTmp = new JPanel();
    long totalDebitClasse = 0;
    long totalCreditClasse = 0;

    panelTmp.setLayout(new GridBagLayout());
    panelTmp.setOpaque(false);
    final GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 1, 2);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 0;

    // Rcupration des comptes de la classe avec le total
    SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
    SQLTable compteTable = base.getTable("COMPTE_PCE");
    SQLTable ecritureTable = base.getTable("ECRITURE");

    SQLSelect sel = new SQLSelect(base);
    sel.addSelect(compteTable.getKey());
    sel.addSelect(compteTable.getField("NUMERO"));
    sel.addSelect(compteTable.getField("NOM"));
    sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
    sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");

    String function = "REGEXP";
    String match = cc.getTypeNumeroCompte();
    if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
        // function = "SIMILAR TO";
        function = "~";
        // match = cc.getTypeNumeroCompte().replace(".*", "%");
    }

    Where w = new Where(compteTable.getField("NUMERO"), function, match);
    Where w2 = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", compteTable.getKey());

    if (!UserManager.getInstance().getCurrentUser().getRights()
            .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
        // TODO Show Restricted acces in UI
        w = w.and(new Where(ecritureTable.getField("COMPTE_NUMERO"), "LIKE", "411%"));
    }

    sel.setWhere(w.and(w2));

    String req = sel.asString()
            + " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\",\"COMPTE_PCE\".\"NOM\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
    System.out.println(req);

    Object ob = base.getDataSource().execute(req, new ArrayListHandler());

    List myList = (List) ob;

    JLabel labelTotalClasse = new JLabel();
    labelTotalClasse.setOpaque(false);
    if (myList.size() != 0) {

        /***************************************************************************************
         * Cration des Panels de chaque compte
         **************************************************************************************/
        // c.weighty = 1;
        for (int i = 0; i < myList.size(); i++) {

            Object[] objTmp = (Object[]) myList.get(i);

            final Compte compteTmp = new Compte(((Number) objTmp[0]).intValue(), objTmp[1].toString(),
                    objTmp[2].toString(), "", ((Number) objTmp[3]).longValue(),
                    ((Number) objTmp[4]).longValue());

            c.fill = GridBagConstraints.HORIZONTAL;
            c.weightx = 1;
            c.weighty = 0;
            c.gridx = 0;
            c.gridy++;
            panelTmp.add(creerComptePanel(compteTmp), c);

            // calcul du total de la classe
            totalDebitClasse += compteTmp.getTotalDebit();
            totalCreditClasse += compteTmp.getTotalCredit();
        }

        // Total de la classe
        labelTotalClasse.setText(
                "Total Classe " + cc.getNom() + " Dbit : " + GestionDevise.currencyToString(totalDebitClasse)
                        + " Crdit : " + GestionDevise.currencyToString(totalCreditClasse));

    } else {
        labelTotalClasse.setHorizontalAlignment(SwingConstants.CENTER);
        labelTotalClasse.setText("Aucune criture pour la classe " + cc.getNom());
    }
    c.gridy++;
    c.weighty = 1;
    panelTmp.add(labelTotalClasse, c);

    return panelTmp;
}

From source file:org.openconcerto.task.TodoListPanel.java

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    JLabel label = (JLabel) this.renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
            column);//from  w w w .j av  a 2  s  .  co m
    label.setIcon(this.icon);
    label.setBorder(BorderFactory.createEmptyBorder());
    label.setIconTextGap(0);
    label.setHorizontalTextPosition(0);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    return label;
}

From source file:org.openflexo.technologyadapter.excel.view.ExcelSheetView.java

public ExcelSheetView(ExcelSheet sheet, FlexoController controller) {
    super(new BorderLayout());
    this.sheet = sheet;
    this.controller = controller;
    tableModel = new ExcelSheetTableModel();
    table = new MultiSpanCellTable(tableModel);
    table.setBackground(Color.WHITE);
    table.setShowGrid(true);/*www . ja  v  a  2 s .  co  m*/
    table.setGridColor(Color.LIGHT_GRAY);
    table.setRowMargin(0);
    table.getColumnModel().setColumnMargin(0);

    for (int i = 0; i < tableModel.getColumnCount(); i++) {
        TableColumn col = table.getColumnModel().getColumn(i);
        if (i == 0) {
            col.setWidth(25);
            col.setPreferredWidth(25);
            col.setMinWidth(25);
            col.setMaxWidth(100);
            // col.setResizable(false);
            col.setHeaderValue(null);
        } else {
            col.setWidth(sheet.getSheet().getColumnWidth(i - 1) / 40);
            col.setPreferredWidth(sheet.getSheet().getColumnWidth(i - 1) / 40);
            col.setHeaderValue("" + Character.toChars(i + 64)[0]);
        }
    }
    table.setDefaultRenderer(Object.class, new ExcelSheetCellRenderer());
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    add(new JScrollPane(table), BorderLayout.CENTER);

    cellIdentifier = new JTextField(6);
    cellIdentifier.setEditable(false);
    cellIdentifier.setHorizontalAlignment(SwingConstants.CENTER);
    cellValue = new JTextField();
    cellValue.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            valueEditedForSelectedCell(cellValue.getText());
        }
    });
    /*cellValue.getDocument().addDocumentListener(new DocumentListener() {
       @Override
       public void removeUpdate(DocumentEvent e) {
    valueEditedForSelectedCell(cellValue.getText());
       }
            
       @Override
       public void insertUpdate(DocumentEvent e) {
    valueEditedForSelectedCell(cellValue.getText());
       }
            
       @Override
       public void changedUpdate(DocumentEvent e) {
    valueEditedForSelectedCell(cellValue.getText());
       }
    });*/
    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(cellIdentifier, BorderLayout.WEST);
    topPanel.add(cellValue, BorderLayout.CENTER);
    add(topPanel, BorderLayout.NORTH);

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            selectionChanged();
        }
    });
    table.getColumnModel().addColumnModelListener(new TableColumnModelListener() {

        @Override
        public void columnSelectionChanged(ListSelectionEvent e) {
            selectionChanged();
        }

        @Override
        public void columnRemoved(TableColumnModelEvent e) {
        }

        @Override
        public void columnMoved(TableColumnModelEvent e) {
        }

        @Override
        public void columnMarginChanged(ChangeEvent e) {
        }

        @Override
        public void columnAdded(TableColumnModelEvent e) {
        }
    });

    updateRowHeights();

    validate();

    /*for (Object p : sheet.getSheet().getWorkbook().getAllPictures()) {
       System.out.println("Picture: " + p);
    }
            
    System.out.println("class = " + sheet.getSheet().getClass());
            
    if (sheet.getSheet() instanceof HSSFSheet) {
            
       List<HSSFShape> shapes = ((HSSFSheet) sheet.getSheet()).getDrawingPatriarch().getChildren();
       System.out.println("Prout=" + shapes);
       for (int i = 0; i < shapes.size(); i++) {
    System.out.println("hop avec " + shapes.get(i));
    if (shapes.get(i) instanceof HSSFPicture) {
       HSSFPicture pic = (HSSFPicture) shapes.get(i);
       HSSFPictureData picdata = ((HSSFSheet) sheet.getSheet()).getWorkbook().getAllPictures().get(pic.getPictureIndex());
            
       System.out.println("New picture found : " + pic);
       System.out.println("Anchor : " + pic.getAnchor());
       System.out.println("file extension " + picdata.suggestFileExtension());
            
       // int pictureIndex = this.newSheet.getWorkbook().addPicture( picdata.getData(), picdata.getFormat());
            
       // this.newSheet.createDrawingPatriarch().createPicture((HSSFClientAnchor)pic.getAnchor()r, pictureIndex);
            
    }
            
       }
    }*/
}

From source file:org.openuat.apps.OpenUATtoolkit.java

private void initUI() {

    frame = new JFrame("OpenUAT Toolkit");
    frame.setSize(1000, 1000);//from  w ww  .  j a  v  a2s.  co  m
    frame.setLocation(100, 100);
    JPanel pane = new JPanel();
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));

    java.net.URL printerImage = getClass().getResource("/printer_bg.png");

    ImageIcon printerIcon = new ImageIcon(printerImage);
    pane.add(new JLabel("Print service started", printerIcon, SwingConstants.CENTER));
    //      pane.add(new JLabel("Available input/output methods: button, small display, audio", null, SwingConstants.CENTER));

    pane.add(status);
    pane.add(progress);
    pane.setBorder(BorderFactory.createRaisedBevelBorder());
    frame.setContentPane(pane);
    frame.setVisible(true);
}

From source file:org.optaplanner.examples.meetingscheduling.swingui.MeetingSchedulingPanel.java

private void fillRoomCells(MeetingSchedule meetingSchedule) {
    for (Room room : meetingSchedule.getRoomList()) {
        roomsPanel.addRowHeader(HEADER_COLUMN, room,
                createTableHeader(new JLabel(room.getLabel(), SwingConstants.CENTER)));
    }/*from w w w .j ava2s.  c om*/
    roomsPanel.addRowHeader(HEADER_COLUMN, null,
            createTableHeader(new JLabel("Unassigned", SwingConstants.CENTER)));
}

From source file:org.optaplanner.examples.meetingscheduling.swingui.MeetingSchedulingPanel.java

private void fillPersonCells(MeetingSchedule meetingSchedule) {
    for (Person person : meetingSchedule.getPersonList()) {
        personsPanel.addRowHeader(HEADER_COLUMN_GROUP1, Pair.of(person, Boolean.TRUE), HEADER_COLUMN_GROUP1,
                Pair.of(person, Boolean.FALSE),
                createTableHeader(new JLabel(person.getLabel(), SwingConstants.CENTER)));
        personsPanel.addRowHeader(HEADER_COLUMN, Pair.of(person, Boolean.TRUE),
                createTableHeader(new JLabel("Required", SwingConstants.CENTER)));
        personsPanel.addRowHeader(HEADER_COLUMN, Pair.of(person, Boolean.FALSE),
                createTableHeader(new JLabel("Preferred", SwingConstants.CENTER)));
    }//from www .  j  a va 2 s.  c  o m
}

From source file:org.photovault.swingui.color.ColorSettingsDlg.java

/**
 Get a standard sized label for the sliders.
 @param txt Text to show in label.//from w w w. j a  va  2 s  . co  m
 @return Label.
 */
private JComponent getSliderLabel(String txt) {
    if (sliderLabelDimension == null) {
        JLabel maxLabel = new JLabel(String.valueOf(12000));
        sliderLabelDimension = maxLabel.getPreferredSize();
    }
    JLabel l = new JLabel(txt, SwingConstants.CENTER);
    l.setPreferredSize(sliderLabelDimension);
    return l;
}