Example usage for javax.swing JTextField getWidth

List of usage examples for javax.swing JTextField getWidth

Introduction

In this page you can find the example usage for javax.swing JTextField getWidth.

Prototype

@BeanProperty(bound = false)
public int getWidth() 

Source Link

Document

Returns the current width of this component.

Usage

From source file:city_planning.initialize_fields.Initialize_search_record_field_types.java

public static void init_puroks(final JTextField tf) {

    Object[][] obj = new Object[puroks.size()][1];
    int i = 0;//  w  w  w  .ja v  a  2s . com
    for (Puroks.to_puroks to : puroks) {
        obj[i][0] = " " + to.purok;
        i++;
    }
    JLabel[] labels = {};
    int[] tbl_widths_customers = { tf.getWidth() };
    String[] col_names = { "Name" };
    TableRenderer tr = new TableRenderer();
    TableRenderer.setPopup(tf, obj, labels, tbl_widths_customers, col_names);
    tr.setCallback(new TableRenderer.Callback() {
        @Override
        public void ok(TableRenderer.OutputData data) {
            Puroks.to_puroks to = puroks.get(data.selected_row);
            Field.Combo field = (Field.Combo) tf;
            field.setText(to.purok);
            field.setId("" + to.id);
        }
    });
}

From source file:city_planning.initialize_fields.Initialize_search_record_field_types.java

public static void init_barangays(final JTextField tf) {

    Object[][] obj = new Object[barangays.size()][1];
    int i = 0;//from   w w w .  j a v a  2 s.co  m
    for (Barangays.to_barangays to : barangays) {
        obj[i][0] = " " + to.barangay;
        i++;
    }
    JLabel[] labels = {};
    int[] tbl_widths_customers = { tf.getWidth() };
    String[] col_names = { "Name" };
    TableRenderer tr = new TableRenderer();
    TableRenderer.setPopup(tf, obj, labels, tbl_widths_customers, col_names);
    tr.setCallback(new TableRenderer.Callback() {
        @Override
        public void ok(TableRenderer.OutputData data) {
            Barangays.to_barangays to = barangays.get(data.selected_row);
            Field.Combo field = (Field.Combo) tf;
            field.setText(to.barangay);
            field.setId("" + to.id);
        }
    });
}

From source file:city_planning.initialize_fields.Initialize_search_record_field_types.java

public static void init_cities(final JTextField tf) {

    Object[][] obj = null;/*from   ww  w  .  j  a  v a  2s.co m*/
    int i = 0;
    if (tf.getText().isEmpty()) {
        obj = new Object[cities.size()][1];
        for (Cities.to_cities to : cities) {
            obj[i][0] = " " + to.city;
            i++;
        }
    } else {
        List<Cities.to_cities> in_search = new ArrayList();
        for (Cities.to_cities to : cities) {
            boolean contains = StringUtils.containsIgnoreCase(to.city, tf.getText());
            if (contains) {
                in_search.add(to);
            }
        }
        obj = new Object[in_search.size()][1];
        for (Cities.to_cities to : in_search) {
            obj[i][0] = " " + to.city;
            i++;
        }
    }

    JLabel[] labels = {};
    int[] tbl_widths_customers = { tf.getWidth() };
    String[] col_names = { "Name" };
    TableRenderer tr = new TableRenderer();
    TableRenderer.setPopup(tf, obj, labels, tbl_widths_customers, col_names);
    tr.setCallback(new TableRenderer.Callback() {
        @Override
        public void ok(TableRenderer.OutputData data) {
            Cities.to_cities to = cities.get(data.selected_row);
            Field.Combo field = (Field.Combo) tf;
            field.setText(to.city);
            field.setId("" + to.id);

        }
    });
}

From source file:city_planning.initialize_fields.Initialize_search_record_field_types.java

public static void init_regions(final JTextField tf) {

    Object[][] obj = null;//from   w  w  w  .  ja va 2 s. co m
    int i = 0;
    if (tf.getText().isEmpty()) {
        obj = new Object[regions.size()][1];
        for (Regions.to_regions to : regions) {
            obj[i][0] = " " + to.region;
            i++;
        }
    } else {
        List<Regions.to_regions> in_search = new ArrayList();
        for (Regions.to_regions to : regions) {
            boolean contains = StringUtils.containsIgnoreCase(to.region, tf.getText());
            if (contains) {
                in_search.add(to);
            }
        }
        obj = new Object[in_search.size()][1];
        for (Regions.to_regions to : in_search) {
            obj[i][0] = " " + to.region;
            i++;
        }
    }

    JLabel[] labels = {};
    int[] tbl_widths_customers = { tf.getWidth() };
    String[] col_names = { "Name" };
    TableRenderer tr = new TableRenderer();
    TableRenderer.setPopup(tf, obj, labels, tbl_widths_customers, col_names);
    tr.setCallback(new TableRenderer.Callback() {
        @Override
        public void ok(TableRenderer.OutputData data) {
            Regions.to_regions to = regions.get(data.selected_row);
            Field.Combo field = (Field.Combo) tf;
            field.setText(to.region);
            field.setId("" + to.id);
        }
    });
}

From source file:city_planning.initialize_fields.Initialize_search_record_field_types.java

public static void init_provinces(final JTextField tf, final JTextField tf_regions) {

    Object[][] obj = null;//from w w  w  . j  a  va  2  s . c  o  m
    int i = 0;
    if (tf.getText().isEmpty()) {
        obj = new Object[provinces.size()][1];
        for (Provinces.to_provinces to : provinces) {
            obj[i][0] = " " + to.province;
            i++;
        }
    } else {
        List<Provinces.to_provinces> in_search = new ArrayList();
        for (Provinces.to_provinces to : provinces) {
            boolean contains = StringUtils.containsIgnoreCase(to.province, tf.getText());
            if (contains) {
                in_search.add(to);
            }
        }
        obj = new Object[in_search.size()][1];
        for (Provinces.to_provinces to : in_search) {
            obj[i][0] = " " + to.province;
            i++;
        }
    }

    JLabel[] labels = {};
    int[] tbl_widths_customers = { tf.getWidth() };
    String[] col_names = { "Name" };
    TableRenderer tr = new TableRenderer();
    TableRenderer.setPopup(tf, obj, labels, tbl_widths_customers, col_names);
    tr.setCallback(new TableRenderer.Callback() {
        @Override
        public void ok(TableRenderer.OutputData data) {
            Provinces.to_provinces to = provinces.get(data.selected_row);
            Field.Combo field = (Field.Combo) tf;
            Field.Combo field_region = (Field.Combo) tf_regions;
            field.setText(to.province);
            field.setId("" + to.id);

            field_region.setText(to.region);
            field_region.setId(to.region_id);

        }
    });
}

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

private void initTable(int mode) {
    this.t.setBlockRepaint(true);

    this.t.setBlockEventOnColumn(true);
    this.model.setMode(mode);

    this.t.getColumnModel().getColumn(0).setCellRenderer(this.a);
    this.t.getColumnModel().getColumn(0).setCellEditor(this.a);
    this.t.setBlockEventOnColumn(true);
    setIconForColumn(0, this.iconTache);
    setIconForColumn(1, this.iconPriorite);
    this.t.setBlockEventOnColumn(true);

    this.t.getColumnModel().getColumn(1).setCellEditor(this.iconEditor);
    final JTextField textField = new JTextField() {
        @Override//w w  w .j a  va 2s . c  o  m
        public void paint(Graphics g) {
            super.paint(g);
            g.setColor(TodoListPanel.this.t.getGridColor());
            g.fillRect(getWidth() - 19, 0, 1, getHeight());
            g.setColor(new Color(250, 250, 250));
            g.fillRect(getWidth() - 18, 0, 18, getHeight());
            g.setColor(Color.BLACK);
            for (int i = 0; i < 3; i++) {
                int x = getWidth() - 14 + i * 4;
                int y = getHeight() - 5;
                g.fillRect(x, y, 1, 2);
            }
        }
    };
    textField.setBorder(BorderFactory.createEmptyBorder());
    final DefaultCellEditor defaultCellEditor = new DefaultCellEditor(textField);
    textField.addMouseListener(new MouseListener() {

        public void mouseClicked(MouseEvent e) {

        }

        public void mouseEntered(MouseEvent e) {
            // TODO Auto-generated method stub

        }

        public void mouseExited(MouseEvent e) {
            // TODO Auto-generated method stub

        }

        public void mousePressed(MouseEvent e) {

        }

        public void mouseReleased(MouseEvent e) {
            if (e.getX() > textField.getWidth() - 19) {
                TodoListElement l = getTaskAt(
                        SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), TodoListPanel.this.t));
                TodoListPanel.this.t.editingCanceled(new ChangeEvent(this));
                JFrame f = new JFrame(TM.tr("details"));
                f.setContentPane(new TodoListElementEditorPanel(l));
                f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                f.setSize(500, 200);
                f.setLocation(50, e.getYOnScreen() + TodoListPanel.this.t.getRowHeight());
                f.setVisible(true);
            }

        }
    });
    this.t.getColumnModel().getColumn(2).setCellEditor(defaultCellEditor);
    this.t.getColumnModel().getColumn(3).setMaxWidth(300);
    this.t.getColumnModel().getColumn(3).setMinWidth(100);

    this.timestampTableCellEditorCreated.stopCellEditing();
    this.timestampTableCellEditorDone.stopCellEditing();
    this.timestampTableCellEditorDeadLine.stopCellEditing();

    if (this.model.getMode() == TodoListModel.EXTENDED_MODE) {
        this.t.getColumnModel().getColumn(3).setCellRenderer(this.timestampTableCellRendererCreated);
        this.t.getColumnModel().getColumn(3).setCellEditor(this.timestampTableCellEditorCreated);

        this.t.getColumnModel().getColumn(4).setCellRenderer(this.timestampTableCellRendererDone);
        this.t.getColumnModel().getColumn(4).setCellEditor(this.timestampTableCellEditorDone);

        this.t.getColumnModel().getColumn(5).setCellRenderer(this.timestampTableCellRendererDeadLine);
        this.t.getColumnModel().getColumn(5).setCellEditor(this.timestampTableCellEditorDeadLine);
    } else {
        this.t.getColumnModel().getColumn(3).setCellRenderer(this.timestampTableCellRendererDeadLine);
        this.t.getColumnModel().getColumn(3).setCellEditor(this.timestampTableCellEditorDeadLine);
    }

    final TableColumn userColumn = this.t.getColumnModel()
            .getColumn(this.t.getColumnModel().getColumnCount() - 1);
    userColumn.setCellRenderer(this.userTableCellRenderer);
    userColumn.setMaxWidth(150);
    userColumn.setMinWidth(100);
    t.setEnabled(false);
    initUserCellEditor(userColumn);

    this.t.setBlockEventOnColumn(false);
    this.t.setBlockRepaint(false);
    this.t.getColumnModel().getColumn(1).setCellRenderer(this.iconRenderer);
    // Better look
    this.t.setShowHorizontalLines(false);
    this.t.setGridColor(new Color(230, 230, 230));
    this.t.setRowHeight(new JTextField(" ").getPreferredSize().height + 4);
    AlternateTableCellRenderer.UTILS.setAllColumns(this.t);
    this.t.repaint();

}