Example usage for javax.swing.table DefaultTableCellRenderer setHorizontalTextPosition

List of usage examples for javax.swing.table DefaultTableCellRenderer setHorizontalTextPosition

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableCellRenderer setHorizontalTextPosition.

Prototype

@BeanProperty(expert = true, visualUpdate = true, enumerationValues = { "SwingConstants.LEFT",
        "SwingConstants.CENTER", "SwingConstants.RIGHT", "SwingConstants.LEADING",
        "SwingConstants.TRAILING" }, description = "The horizontal position of the label's text, relative to its image.")
public void setHorizontalTextPosition(int textPosition) 

Source Link

Document

Sets the horizontal position of the label's text, relative to its image.

Usage

From source file:de.mprengemann.intellij.plugin.androidicons.dialogs.AndroidBatchScaleImporter.java

private void initRenderers() {
    final DefaultTableCellRenderer fileCellRenderer = new DefaultTableCellRenderer() {
        @Override/*ww w .  ja v a2  s  .c  om*/
        protected void setValue(Object o) {
            File file = (File) o;
            if (file == null) {
                setText("");
                return;
            }
            if (file.isDirectory()) {
                setText(file.getAbsolutePath());
            } else {
                setText(FilenameUtils.removeExtension(file.getName()));
            }
        }
    };
    fileCellRenderer.setHorizontalTextPosition(DefaultTableCellRenderer.TRAILING);
    table.setDefaultRenderer(File.class, fileCellRenderer);
    table.setDefaultRenderer(ArrayList.class, new DefaultTableCellRenderer() {
        @Override
        protected void setValue(Object o) {
            if (o == null) {
                setText("");
            } else {
                ArrayList list = (ArrayList) o;
                Collections.sort(list);
                StringBuilder buffer = new StringBuilder();
                Iterator iterator = list.iterator();
                while (iterator.hasNext()) {
                    Object val = iterator.next();
                    buffer.append(val.toString());
                    if (iterator.hasNext()) {
                        buffer.append(", ");
                    }
                }
                setText(buffer.toString());
            }
        }
    });
}

From source file:de.mprengemann.intellij.plugin.androidicons.forms.AndroidBatchScaleImporter.java

private void initRenderers() {
    DefaultTableCellRenderer fileCellRenderer = new DefaultTableCellRenderer() {
        @Override/*w w  w.  j  av  a  2  s. c  om*/
        protected void setValue(Object o) {
            File file = (File) o;
            if (file == null) {
                setText("");
                return;
            }
            if (file.isDirectory()) {
                setText(file.getAbsolutePath());
            } else {
                setText(FilenameUtils.removeExtension(file.getName()));
            }

        }
    };
    fileCellRenderer.setHorizontalTextPosition(DefaultTableCellRenderer.RIGHT);
    table.setDefaultRenderer(File.class, fileCellRenderer);
    table.setDefaultRenderer(Resolution.class, new DefaultTableCellRenderer() {
        @Override
        protected void setValue(Object o) {
            if (o == null) {
                setText("");
            } else {
                setText(((Resolution) o).getName());
            }
        }
    });
    table.getColumnModel().getColumn(6).setCellEditor(new TextBrowserEditor());
}