JTable ToolTip in two lines

Hello everybody,
Please advise me how to make a JTable ToolTip to be displayed in two lines
Thanks,
Elena

Use HTML tags to split tool tip text between two lines. For example:
JTable table = new JTable();
table.setToolTipText("<html>This table's tool tip text<br>is split between two lines</html>");

Similar Messages

  • I want to delete two lines across the top of the browser page. One is an inbox search window, the other a yahoo search window.

    The two lines I wish to delete are toolbars.

    Is there any text in that gray bar?
    I see some buttons on it, do they have a tooltip?
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    Are you using a proxy to connect to the internet?
    See "Firefox connection settings":
    *https://support.mozilla.org/kb/Firefox+cannot+load+websites+but+other+programs+can

  • JTable header : text = two-rows, onClick action = sorting

    Hi guys.
    I want to create a JTable where the user can have the data sorted by clicking upon a column's header. The code below shows the table I describe (you can click upon a column and sorting is performed).
    import javax.swing.JFrame;
    import java.awt.HeadlessException;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.util.Vector;
    import javax.swing.table.DefaultTableModel;
    //--------- TableSorter ----------
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.*;
    //---------- Table Height - Column Width
    import javax.swing.table.TableColumn;
    import java.awt.FontMetrics;
    import javax.swing.JTable;
    import java.awt.Dimension;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2006</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Test extends JFrame {
      JPanel jPanel1 = new JPanel();
      JPanel jPanel2 = new JPanel();
      JButton jButton1 = new JButton();
      FlowLayout flowLayout1 = new FlowLayout();
      BorderLayout borderLayout1 = new BorderLayout();
      BorderLayout borderLayout2 = new BorderLayout();
      //------------- MY VARIABLES -------------
      String[] columnNames_objectArr = new String[] {
          "Col1",
          "Column 2",
          "Column 3",
          "C4",
          "Col5",
          "Col 6",
      Vector columnNames_vector = new Vector();
      private Vector data_vector = new Vector();
      private Object[][] data_objectArr;
      public TableHeight_ColumnWidth tcw;
      private int totalTableWidth = 0, totalTableHeight = 0;
      private JComboBox jcmbxData = new JComboBox(
          new String[] {"Not Configured", "Switch", "Modem"});
      private int maxVisibleRows = 51;
      TableSorter model;
      private JTable table;
      JScrollPane jScrollPane1;
      public Test(String[] args) throws HeadlessException {
        try {
          jbInit();
          setupGUI();
          launchGUI();
        catch(Exception e) {
          e.printStackTrace();
      private void jbtnClose_actionPerformed(ActionEvent e) {
        dispose();
      private void launchGUI() {
        pack();
        setVisible(true);
        setResizable(false);
      private void setupGUI() {
        columnNames_vector.addElement("Col1");
        columnNames_vector.addElement("Column 2");
        columnNames_vector.addElement("Column 3");
        columnNames_vector.addElement("C4");
        columnNames_vector.addElement("Col5");
        columnNames_vector.addElement("Col 6");
        Vector row_data1 = new Vector();
        Vector row_data2 = new Vector();
        Vector row_data3 = new Vector();
        Vector row_data4 = new Vector();
        Vector row_data5 = new Vector();
        Vector row_data6 = new Vector();
        row_data1.add("Mary");
        row_data1.add("Campioneato");
        row_data1.add("Snowboarding");
        row_data1.add(new Integer(578987899));
        row_data1.add(new Boolean(false));
        row_data1.add("Not Configured");
        row_data2.add("Alison");
        row_data2.add("Huml");
        row_data2.add("Rowing");
        row_data2.add(new Integer(3));
        row_data2.add(new Boolean(true));
        row_data2.add("Switch");
        row_data3.add("Ka");
        row_data3.add("Walrath");
        row_data3.add("Knitting");
        row_data3.add(new Integer(2));
        row_data3.add(new Boolean(false));
        row_data3.add("Modem");
        row_data4.add("Sharon");
        row_data4.add("Zakhouras");
        row_data4.add("Speed reading");
        row_data4.add(new Integer(20));
        row_data4.add(new Boolean(true));
        row_data4.add("Switch");
        row_data5.add("Philip");
        row_data5.add("Milner");
        row_data5.add("Pool");
        row_data5.add(new Integer(10));
        row_data5.add(new Boolean(false));
        row_data5.add("Not Configured");
        data_vector.add(row_data1);
        data_vector.add(row_data2);
        data_vector.add(row_data3);
        data_vector.add(row_data4);
        data_vector.add(row_data5);
        model = new TableSorter(new SortTableModel(data_vector, columnNames_vector));
        table = new JTable(model);
        tcw = new TableHeight_ColumnWidth(model, table);
        jScrollPane1 = new JScrollPane(table);
        model.setTableHeader(table.getTableHeader());
        jPanel1.add(jScrollPane1, BorderLayout.CENTER);
        //Add a JComboBox as a cellEditor...
        DefaultCellEditor dce = new DefaultCellEditor(jcmbxData);
        table.getColumnModel().getColumn(5).setCellEditor(dce);
        //..... add the IPJPanel as cellEditor.....
        tcw.fixTableLook(maxVisibleRows);
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(borderLayout2);
        jPanel1.setLayout(borderLayout1);
        jPanel2.setLayout(flowLayout1);
        jButton1.setText("Close");
        jPanel1.setBorder(BorderFactory.createRaisedBevelBorder());
        this.getContentPane().add(jPanel1, BorderLayout.CENTER);
        this.getContentPane().add(jPanel2, BorderLayout.SOUTH);
        jPanel2.add(jButton1, null);
        jButton1.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jbtnClose_actionPerformed(e);
      public static void main( String[] args ) {
        new Test(args);
      public boolean getScrollableTracksViewportHeight() {
        Component parent = getParent();
        if (parent instanceof JViewport) {
          return parent.getHeight() > getPreferredSize().height;
        return false;
      //------------------ MY TABLE MODEL ------------------
      public class SortTableModel extends DefaultTableModel {
        private boolean DEBUG = false;
        public SortTableModel(Object[][] data, String[] columnNames) {
          super(data, columnNames);
        public SortTableModel(Vector data, Vector columnNames) {
          super(data, columnNames);
      //------------------ TABLE SORTER -----------------------
      public class TableSorter extends AbstractTableModel {
          protected TableModel tableModel;
          public static final int DESCENDING = -1;
          public static final int NOT_SORTED = 0;
          public static final int ASCENDING = 1;
          private Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
          public final Comparator COMPARABLE_COMAPRATOR = new Comparator() {
              public int compare(Object o1, Object o2) {
                  return ((Comparable) o1).compareTo(o2);
          public final Comparator LEXICAL_COMPARATOR = new Comparator() {
              public int compare(Object o1, Object o2) {
                  return o1.toString().compareTo(o2.toString());
          private Row[] viewToModel;
          private int[] modelToView;
          private JTableHeader tableHeader;
          private MouseListener mouseListener;
          private TableModelListener tableModelListener;
          private Map columnComparators = new HashMap();
          private List sortingColumns = new ArrayList();
          public TableSorter() {
              this.mouseListener = new MouseHandler();
              this.tableModelListener = new TableModelHandler();
          public TableSorter(TableModel tableModel) {
              this();
              setTableModel(tableModel);
          public TableSorter(TableModel tableModel, JTableHeader tableHeader) {
              this();
              setTableHeader(tableHeader);
              setTableModel(tableModel);
          private void clearSortingState() {
              viewToModel = null;
              modelToView = null;
          public TableModel getTableModel() {
              return tableModel;
          public void setTableModel(TableModel tableModel) {
              if (this.tableModel != null) {
                  this.tableModel.removeTableModelListener(tableModelListener);
              this.tableModel = tableModel;
              if (this.tableModel != null) {
                  this.tableModel.addTableModelListener(tableModelListener);
              clearSortingState();
              fireTableStructureChanged();
          public JTableHeader getTableHeader() {
              return tableHeader;
          public void setTableHeader(JTableHeader tableHeader) {
              if (this.tableHeader != null) {
                  this.tableHeader.removeMouseListener(mouseListener);
                  TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
                  if (defaultRenderer instanceof SortableHeaderRenderer) {
                      this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
              this.tableHeader = tableHeader;
              if (this.tableHeader != null) {
                  this.tableHeader.addMouseListener(mouseListener);
                  this.tableHeader.setDefaultRenderer(
                          new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
          public boolean isSorting() {
              return sortingColumns.size() != 0;
          private Directive getDirective(int column) {
              for (int i = 0; i < sortingColumns.size(); i++) {
                  Directive directive = (Directive)sortingColumns.get(i);
                  if (directive.column == column) {
                      return directive;
              return EMPTY_DIRECTIVE;
          public int getSortingStatus(int column) {
              return getDirective(column).direction;
          private void sortingStatusChanged() {
              clearSortingState();
              fireTableDataChanged();
              if (tableHeader != null) {
                  tableHeader.repaint();
          public void setSortingStatus(int column, int status) {
              Directive directive = getDirective(column);
              if (directive != EMPTY_DIRECTIVE) {
                  sortingColumns.remove(directive);
              if (status != NOT_SORTED) {
                  sortingColumns.add(new Directive(column, status));
              sortingStatusChanged();
          protected Icon getHeaderRendererIcon(int column, int size) {
              Directive directive = getDirective(column);
              if (directive == EMPTY_DIRECTIVE) {
                  return null;
              return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
          private void cancelSorting() {
              sortingColumns.clear();
              sortingStatusChanged();
          public void setColumnComparator(Class type, Comparator comparator) {
              if (comparator == null) {
                  columnComparators.remove(type);
              } else {
                  columnComparators.put(type, comparator);
          protected Comparator getComparator(int column) {
              Class columnType = tableModel.getColumnClass(column);
              Comparator comparator = (Comparator) columnComparators.get(columnType);
              if (comparator != null) {
                  return comparator;
              if (Comparable.class.isAssignableFrom(columnType)) {
                  return COMPARABLE_COMAPRATOR;
              return LEXICAL_COMPARATOR;
          private Row[] getViewToModel() {
              if (viewToModel == null) {
                  int tableModelRowCount = tableModel.getRowCount();
                  viewToModel = new Row[tableModelRowCount];
                  for (int row = 0; row < tableModelRowCount; row++) {
                      viewToModel[row] = new Row(row);
                  if (isSorting()) {
                      Arrays.sort(viewToModel);
              return viewToModel;
          public int modelIndex(int viewIndex) {
              return getViewToModel()[viewIndex].modelIndex;
          private int[] getModelToView() {
              if (modelToView == null) {
                  int n = getViewToModel().length;
                  modelToView = new int[n];
                  for (int i = 0; i < n; i++) {
                      modelToView[modelIndex(i)] = i;
              return modelToView;
          // TableModel interface methods
          public int getRowCount() {
              return (tableModel == null) ? 0 : tableModel.getRowCount();
          public int getColumnCount() {
              return (tableModel == null) ? 0 : tableModel.getColumnCount();
          public String getColumnName(int column) {
              return tableModel.getColumnName(column);
          public Class getColumnClass(int column) {
              return tableModel.getColumnClass(column);
          public boolean isCellEditable(int row, int column) {
              return tableModel.isCellEditable(modelIndex(row), column);
          public Object getValueAt(int row, int column) {
              return tableModel.getValueAt(modelIndex(row), column);
          public void setValueAt(Object aValue, int row, int column) {
              tableModel.setValueAt(aValue, modelIndex(row), column);
          // Helper classes
          private class Row implements Comparable {
              private int modelIndex;
              public Row(int index) {
                  this.modelIndex = index;
              public int compareTo(Object o) {
                  int row1 = modelIndex;
                  int row2 = ((Row) o).modelIndex;
                  for (Iterator it = sortingColumns.iterator(); it.hasNext();) {
                      Directive directive = (Directive) it.next();
                      int column = directive.column;
                      Object o1 = tableModel.getValueAt(row1, column);
                      Object o2 = tableModel.getValueAt(row2, column);
                      int comparison = 0;
                      // Define null less than everything, except null.
                      if (o1 == null && o2 == null) {
                          comparison = 0;
                      } else if (o1 == null) {
                          comparison = -1;
                      } else if (o2 == null) {
                          comparison = 1;
                      } else {
                          comparison = getComparator(column).compare(o1, o2);
                      if (comparison != 0) {
                          return directive.direction == DESCENDING ? -comparison : comparison;
                  return 0;
          private class TableModelHandler implements TableModelListener {
              public void tableChanged(TableModelEvent e) {
                  // If we're not sorting by anything, just pass the event along.
                  if (!isSorting()) {
                      clearSortingState();
                      fireTableChanged(e);
                      return;
                  // If the table structure has changed, cancel the sorting; the
                  // sorting columns may have been either moved or deleted from
                  // the model.
                  if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
                      cancelSorting();
                      fireTableChanged(e);
                      return;
                  // We can map a cell event through to the view without widening
                  // when the following conditions apply:
                  // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
                  // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
                  // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
                  // d) a reverse lookup will not trigger a sort (modelToView != null)
                  // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
                  // The last check, for (modelToView != null) is to see if modelToView
                  // is already allocated. If we don't do this check; sorting can become
                  // a performance bottleneck for applications where cells
                  // change rapidly in different parts of the table. If cells
                  // change alternately in the sorting column and then outside of
                  // it this class can end up re-sorting on alternate cell updates -
                  // which can be a performance problem for large tables. The last
                  // clause avoids this problem.
                  int column = e.getColumn();
                  if (e.getFirstRow() == e.getLastRow()
                          && column != TableModelEvent.ALL_COLUMNS
                          && getSortingStatus(column) == NOT_SORTED
                          && modelToView != null) {
                      int viewIndex = getModelToView()[e.getFirstRow()];
                      fireTableChanged(new TableModelEvent(TableSorter.this,
                                                           viewIndex, viewIndex,
                                                           column, e.getType()));
                      return;
                  // Something has happened to the data that may have invalidated the row order.
                  clearSortingState();
                  fireTableDataChanged();
                  return;
          private class MouseHandler extends MouseAdapter {
              public void mouseClicked(MouseEvent e) {
                  JTableHeader h = (JTableHeader) e.getSource();
                  TableColumnModel columnModel = h.getColumnModel();
                  int viewColumn = columnModel.getColumnIndexAtX(e.getX());
                  int column = columnModel.getColumn(viewColumn).getModelIndex();
                  if (column != -1) {
                      int status = getSortingStatus(column);
                      if (!e.isControlDown()) {
                          cancelSorting();
                      // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                      // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                      status = status + (e.isShiftDown() ? -1 : 1);
                      status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
                      setSortingStatus(column, status);
          private class Arrow implements Icon {
              private boolean descending;
              private int size;
              private int priority;
              public Arrow(boolean descending, int size, int priority) {
                  this.descending = descending;
                  this.size = size;
                  this.priority = priority;
              public void paintIcon(Component c, Graphics g, int x, int y) {
                  Color color = c == null ? Color.GRAY : c.getBackground();
                  // In a compound sort, make each succesive triangle 20%
                  // smaller than the previous one.
                  int dx = (int)(size/2*Math.pow(0.8, priority));
                  int dy = descending ? dx : -dx;
                  // Align icon (roughly) with font baseline.
                  y = y + 5*size/6 + (descending ? -dy : 0);
                  int shift = descending ? 1 : -1;
                  g.translate(x, y);
                  // Right diagonal.
                  g.setColor(color.darker());
                  g.drawLine(dx / 2, dy, 0, 0);
                  g.drawLine(dx / 2, dy + shift, 0, shift);
                  // Left diagonal.
                  g.setColor(color.brighter());
                  g.drawLine(dx / 2, dy, dx, 0);
                  g.drawLine(dx / 2, dy + shift, dx, shift);
                  // Horizontal line.
                  if (descending) {
                      g.setColor(color.darker().darker());
                  } else {
                      g.setColor(color.brighter().brighter());
                  g.drawLine(dx, 0, 0, 0);
                  g.setColor(color);
                  g.translate(-x, -y);
              public int getIconWidth() {
                  return size;
              public int getIconHeight() {
                  return size;
          private class SortableHeaderRenderer implements TableCellRenderer {
              private TableCellRenderer tableCellRenderer;
              public SortableHeaderRenderer(TableCellRenderer tableCellRenderer) {
                  this.tableCellRenderer = tableCellRenderer;
              public Component getTableCellRendererComponent(JTable table,
                                                             Object value,
                                                             boolean isSelected,
                                                             boolean hasFocus,
                                                             int row,
                                                             int column) {
                  Component c = tableCellRenderer.getTableCellRendererComponent(table,
                          value, isSelected, hasFocus, row, column);
                  if (c instanceof JLabel) {
                      JLabel l = (JLabel) c;
                      l.setHorizontalTextPosition(JLabel.LEFT);
                      int modelColumn = table.convertColumnIndexToModel(column);
                      l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
                  return c;
          private class Directive {
              private int column;
              private int direction;
              public Directive(int column, int direction) {
                  this.column = column;
                  this.direction = direction;
      //-------------- FIX TABLE'S HEIGHT & COLUMN WIDTH ---------
      public class TableHeight_ColumnWidth {
        private TableSorter sorter;
        private FontMetrics fm;
        private JTable table;
        private int numOfRows = 0, totalTableHeight = 0, totalTableWidth = 0;
         * Constructor --- it needs the model as well the JTable as parameters
         * @param sorter - the model
         * @param table - the JTable created based on the model
        public TableHeight_ColumnWidth(TableSorter sorter, JTable table) {
          this.sorter = sorter;
          this.table = table;
          this.fm = table.getFontMetrics(table.getFont());
          this.numOfRows = table.getRowCount();
         * Calculates the width of each column according to the String it contains
         * @param col = the desired column
         * @param fm = the FontMetrics of this column
         * @return - the width of the single column
        public int determineColumnWidth(TableColumn col, FontMetrics fm) {
          int headerWidth = fm.stringWidth((String)col.getHeaderValue());
          int columnNumber = col.getModelIndex();
          int max = headerWidth;
          int columnWidth = 0;
          String cell = "";
          Integer cell_int = new Integer(0);
          Short cell_short = new Short((short)0);
          for (int i = 0; i != sorter.getRowCount(); i++) {
            Object obj = (Object) sorter.getValueAt(i, columnNumber);
            if (obj instanceof String) {
              cell = (String)sorter.getValueAt(i, columnNumber);
            else if (obj instanceof Integer) {
              cell_int = (Integer)sorter.getValueAt(i, columnNumber);
              cell = String.valueOf(cell_int.intValue());
            else if (obj instanceof Short) {
              cell_short = (Short) sorter.getValueAt(i, columnNumber);
              cell = String.valueOf(cell_short.shortValue());
            columnWidth = fm.stringWidth(cell) + 5;
            if (columnWidth > max) {
              max = columnWidth;
          return max + 5;
         * Calculates the total width of the table according to the width of each
         * column.
         * @return - totalTableWidth
        private int fixColumnWidth () {
          int totalTableWidth = 0;
          TableColumn c = null;
          int cw = 0;
          for (int i = 0; i < table.getColumnCount(); i++) {
            c = table.getColumn(table.getColumnName(i));
            cw = this.determineColumnWidth(c, fm);
            c.setPreferredWidth(cw);
            totalTableWidth = totalTableWidth + cw;
            c.setMinWidth(cw);
          return totalTableWidth;
         * Calculates the height of the table according to the height of each row
         * multiplied by 51 (by default) or by the totalRowsCount.
         * @return - totalTableHeight
        private int fixTableHeight(int maxVisibleRows) {
          int rowHeight = table.getRowHeight();
          //Show maxVisibleRows rows maximum
          if (numOfRows > maxVisibleRows) {
            totalTableHeight = rowHeight * maxVisibleRows;
          else {
            totalTableHeight = rowHeight * numOfRows;
          return totalTableHeight;
         * Sets up the table according to the totalTableWidth and totalTableHeight
        public void fixTableLook(int maxVisibleRows) {
          table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
          totalTableWidth = this.fixColumnWidth();
          totalTableHeight = this.fixTableHeight(maxVisibleRows);
          table.setPreferredScrollableViewportSize(new Dimension(totalTableWidth, totalTableHeight));
    }Also, I want some column headers to display their text in two-rows. But by using the HTML technique look at the result in comparison with the previous table I had!
    import javax.swing.JFrame;
    import java.awt.HeadlessException;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.util.Vector;
    import javax.swing.table.DefaultTableModel;
    //--------- TableSorter ----------
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.*;
    //---------- Table Height - Column Width
    import javax.swing.table.TableColumn;
    import java.awt.FontMetrics;
    import javax.swing.JTable;
    import java.awt.Dimension;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2006</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Test extends JFrame {
      JPanel jPanel1 = new JPanel();
      JPanel jPanel2 = new JPanel();
      JButton jButton1 = new JButton();
      FlowLayout flowLayout1 = new FlowLayout();
      BorderLayout borderLayout1 = new BorderLayout();
      BorderLayout borderLayout2 = new BorderLayout();
      //------------- MY VARIABLES -------------
      String[] columnNames_objectArr = new String[] {
          "Col1",
          "Column 2",
          "Column 3",
          "C4",
          "Col5",
          "Col 6",
      Vector columnNames_vector = new Vector();
      private Vector data_vector = new Vector();
      private Object[][] data_objectArr;
      public TableHeight_ColumnWidth tcw;
      private int totalTableWidth = 0, totalTableHeight = 0;
      private JComboBox jcmbxData = new JComboBox(
          new String[] {"Not Configured", "Switch", "Modem"});
      private int maxVisibleRows = 51;
      TableSorter model;
      private JTable table;
      JScrollPane jScrollPane1;
      public Test(String[] args) throws HeadlessException {
        try {
          jbInit();
          setupGUI();
          launchGUI();
        catch(Exception e) {
          e.printStackTrace();
      private void jbtnClose_actionPerformed(ActionEvent e) {
        dispose();
      private void launchGUI() {
        pack();
        setVisible(true);
        setResizable(false);
      private void setupGUI() {
        columnNames_vector.addElement("<html>Col1</html>");
        columnNames_vector.addElement("<html>Column 2</html>");
        columnNames_vector.addElement("<html>Column 3<br>Second Row</html>");
        columnNames_vector.addElement("<html>C4</html>");
        columnNames_vector.addElement("<html>Col5</html>");
        columnNames_vector.addElement("<html>Col 6</html>");
        Vector row_data1 = new Vector();
        Vector row_data2 = new Vector();
        Vector row_data3 = new Vector();
        Vector row_data4 = new Vector();
        Vector row_data5 = new Vector();
        Vector row_data6 = new Vector();
        row_data1.add("Mary");
        row_data1.add("Campioneato");
        row_data1.add("Snowboarding");
        row_data1.add(new Integer(578987899));
        row_data1.add(new Boolean(false));
        row_data1.add("Not Configured");
        row_data2.add("Alison");
        row_data2.add("Huml");
        row_data2.add("Rowing");
        row_data2.add(new Integer(3));
        row_data2.add(new Boolean(true));
        row_data2.add("Switch");
        row_data3.add("Ka");
        row_data3.add("Walrath");
        row_data3.add("Knitting");
        row_data3.add(new Integer(2));
        row_data3.add(new Boolean(false));
        row_data3.add("Modem");
        row_data4.add("Sharon");
        row_data4.add("Zakhouras");
        row_data4.add("Speed reading");
        row_data4.add(new Integer(20));
        row_data4.add(new Boolean(true));
        row_data4.add("Switch");
        row_data5.add("Philip");
        row_data5.add("Milner");
        row_data5.add("Pool");
        row_data5.add(new Integer(10));
        row_data5.add(new Boolean(false));
        row_data5.add("Not Configured");
        data_vector.add(row_data1);
        data_vector.add(row_data2);
        data_vector.add(row_data3);
        data_vector.add(row_data4);
        data_vector.add(row_data5);
        model = new TableSorter(new SortTableModel(data_vector, columnNames_vector));
        table = new JTable(model);
        tcw = new TableHeight_ColumnWidth(model, table);
        jScrollPane1 = new JScrollPane(table);
        model.setTableHeader(table.getTableHeader());
        jPanel1.add(jScrollPane1, BorderLayout.CENTER);
        //Add a JComboBox as a cellEditor...
        DefaultCellEditor dce = new DefaultCellEditor(jcmbxData);
        table.getColumnModel().getColumn(5).setCellEditor(dce);
        //..... add the IPJPanel as cellEditor.....
        tcw.fixTableLook(maxVisibleRows);
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(borderLayout2);
        jPanel1.setLayout(borderLayout1);
        jPanel2.setLayout(flowLayout1);
        jButton1.setText("Close");
        jPanel1.setBorder(BorderFactory.createRaisedBevelBorder());
        this.getContentPane().add(jPanel1, BorderLayout.CENTER);
        this.getContentPane().add(jPanel2, BorderLayout.SOUTH);
        jPanel2.add(jButton1, null);
        jButton1.addActionListener(new ActionListener() {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

    First of all I found out that when I set the column's header like this:
    columnNames_vector.addElement("<html>Column 3<br>Second Row</html>"); //In the setupGUI() methodthe TableHeight_ColumnWidth.determineColumnWidth(TableColumn col, FontMetrics fm) method calculates the column's width by counting <html>, </html>, <br> characters as well. So I added a check to reject these characters and not count them for the column's width.
    As for the header's height:
    I found that when the first column's header is set to display two-lines, then the height of the rest columns headers is set to display two-lines as well. In other words, the height of the first column's header affects the height of the whole JTableHeader.
    I found that the BasicTableHeaderUI.getHeaderHeight() method is called, within which there are these comments:
              // If the header value is empty (== "") in the
              // first column (and this column is set up
              // to use the default renderer) we will
              // return zero from this routine and the header
              // will disappear altogether. Avoiding the calculation
              // of the preferred size is such a performance win for
              // most applications that we will continue to
              // use this cheaper calculation, handling these
              // issues as `edge cases'. Should I override a class and if so which one? I am so confused! If anyone has any idea about how to set the header's height according to the cell's height that is the maximum among all, please let me know.

  • Dynamic Table Two lines per data item

    Hi experts!!
    In my form i have a table with two lines per data item for example the table i want the table to be:
    boldheader rowbold
    bold1,1 1,2bold
    bold1,3 1,4bold
    I have also wrapped the table in a subform, and marked the checkbox "Repeat Row for each data item".
    Instead i get :
    1,1 1,2
    2,1 2,2
    1,3 1,4
    2,3 2,4
    How can i display two rows per item ???
    Thank you in advance!!!

    If there are two lines in a single row for a table (I.e if there are 14 columns, How to be adjusted).
    There are two possible ways of doing.
    1) a) Create a SubForm
        b) Create a Table (If you create a table there will be Header Row and Body Row)
        c) Delete the Body Row and instead of it create a SubForm with name Body Row
        d) Now you have one Header Row and SubForm as BodyRow.
        e) SubForm BodyRow again create two SubForms with names Row1, Row2.
        f) Now make the SubFormBodyRow as Flow layout and repeat the SubForm(Since if you make this then the child nodes (Row1 & Row2) will inherit the properties of the parent node (SubForm-BodyRow).
       g) Now you can have two rows in one lineitem.
    2) The second possible way is showing it in a Dynamic ToolTip.
        Lets say you have a table inside a table then you can show it in a Dynamic ToolTip when you place the cursor in a Student Id you will get Student Data.
    Hope it solves.

  • Field description in two line in ALV report

    Hi ,
    In ALV report I  want the description for each field to be displayed in two lines . For example
    the description for field matnr is " Material No for grade A " which is displayed in one line . But i want to display it as :  Material No
                                                           for grade A
    in two lines . Is it possible . Please help me out .
    Neetesh

    Hi Neetesh,
      Its not possible to display as you like in 2 lines header for single column. But i can provide the alternative way , it won't good logically. Please try the following logic.
    Let suppose you have 10 fields F1-f10. Each field has the 2 lines header. So take 20fields in your fields catalog ie take 10 dummy fields which are equal lenght of the fields F1-f10. and for the last 10 fields(F11-F20) set the row pos as 2, set the second line header to these field(F11-F20). So you will succed to display the 2 level header for single column. But the problem here is you will get one empty row additional row for each row. Because you have taken (F11-F20) fields are dummy and don't have the data also. This solution will works only in the case of ALV List display not in Grid Display.
      But Before that tell to your customer about this problem , Because I have done the same things when my customer giving important to 2 lines header and he accepeted that also.
    If suppose you have the data in 2 lines for each column then this solution will work fine. Thats what i implemented in my ALV Report.
    Warm Regards,
    Vijay.

  • Taking download into excel from ALV Grid - header is printing in two lines

    Hi All,
    I have a scenario where I am taking the download from ALV grid to an excel sheet. Now the header of the ALV (column names) is appearing in two lines in the downloaded excel sheet while items (records of the ALV table) are getting displayed in a single line.
    This download is taken from the standard download to local file (spreadsheet) button provided by SAP for ALVs.
    I am using function module "Reuse_alv_grid_display" for the purpose.
    Can somebody provide an idea how I can avoid the header printing in two lines and keep the length as it is.
    Thanks in Advance,
    Chandan

    Hi..
    1. Pass header name in internal table appned first line.
    2. after that pass u r data .
    3. Use  FM. WS_DOWNLOAD 
    Salil ......
    Edited by: salil chavan on Nov 26, 2008 11:07 AM

  • Unable to find line break between two lines in attachment file.

    Dear all I will be very great full if someone help me out,
    I am trying to send mail through SMTP server with an attachment of oracle report, but I am unable to find line break between two lines, when I down load the attachment from mail and open attach.txt file by double click on it. Next line starts right after previous line ends, it should starts with new line.
    In order to send an attachment file, I am reading source file line by line and put MIME protocol’s attachment instance, contain of source file is being properly written into target file if I open that attachment on cmd prompt.
    Following code may help you to understand the case.
    Thanks in advance.
    My code is as follows:-
    create or replace procedure bec_file_test
    v_subject varchar2, -- Subject of the email
    v_body varchar2, -- Body of the email
    v_from VARCHAR2 default 'XYZ.com', -- sender mail id
    v_to varchar2 default 'XYZ.com', -- Field To of the email
    v_cc varchar2 default 'XYZ.com' -- cc address
    ) is
    -- variable to hold the smtp server connection
    v_smtp_connection utl_smtp.connection;
    -- variable to hold the smtp host name
    v_smtp_host varchar2(100) default 'mail.bec-group.com';
    -- variable to hold the smtp port
    v_smtp_port number default 25;
    -- composite of {CR}{LF} caridge return and line feed.
    CRLF varchar2(2):=CHR(13)||CHR(10);
    cursor pr_rec is
    select requisition_no,line_no,release_no,a.contract,
    a.project_id,substr(a.activity_seq,1,11)ACT_SEQ,
    substr(a.part_no,1,12)PART_NO,
    substr(a.description,1,32)DESCRIPTION,
    substr(a.Bal_qty,1,8) BAL_QTY,
    substr(a.unit_meas,1,5)UOM,
    a.wanted_receipt_date WAN_REC_DT,
    a.latest_order_date LAT_ORD_DT
    from bec_pr_line_rep a
    where a.Bal_qty>0 and a.header_state not in 'Closed'
    and upper(a.state1) like 'RELEASED' and a.contract not in ('U1ENG','ULENG','U1FND','U2FND')
    and a.buyer_code='70306'
    order by a.part_no;
    begin
    declare
    fHandle UTL_FILE.FILE_TYPE;
    v_msg_line varchar2(2000);
    -- v_buffer varchar2(20000);
    --ALTER SYSTEM SET utl_file_dir = 'D:\Database\temp'
    --COMMENT='Temporary change on Dec 14'
    --SCOPE=SPFILE;
    SELECT name, value
    FROM gv$parameter
    WHERE name = 'utl_file_dir';
    --drop directory my_directory
    --CREATE or replace DIRECTORY my_directory AS 'D:\database\temp';
    --GRANT read,write ON DIRECTORY my_directory TO PUBLIC;
    begin ---writing data into a file.
    fHandle := UTL_FILE.FOPEN('MY_DIRECTORY', 'pending_pr_summry.txt', 'w');
    UTL_FILE.put_line(fHandle, ' Pending PR to process (detail report)');
    UTL_FILE.put_line(fHandle,TO_CHAR(SYSDATE,'MM-DD-YY HH:MI:SS AM'));
    UTL_FILE.put_line(fHandle, '--------------------------------------------------------------------------------------------------------------------------------------------------');
    UTL_FILE.put_line(fHandle, 'Req.no. li Re Site Prj Id Act seq Part no Description Qty UOM want rec dt lat ord dt' );
    UTL_FILE.put_line(fHandle, '--------------------------------------------------------------------------------------------------------------------------------------------------');
    for pr_temp in pr_rec loop
    begin
    v_msg_line:=to_char(rpad(pr_temp.requisition_no,12,' ')||'|'||
    lpad(pr_temp.line_no,3,' ')||'|'||
    lpad(pr_temp.release_no,3,' ')||'|'||
    rpad(pr_temp.contract,7,' ')||'|'||
    lpad(nvl(pr_temp.project_id,' '),7,' ')||'|'||
    lpad(nvl(pr_temp.act_seq,' '),12,' ')||'|'||
    lpad(pr_temp.part_no,12,' ')||'|'||
    rpad(pr_temp.description,35,' ')||'|'||
    lpad(pr_temp.bal_qty,10,' ')||'|'||
    rpad(pr_temp.uom,6,' ')||'|'||
    lpad(pr_temp.wan_rec_dt,14,' ')||'|'||
    lpad(pr_temp.lat_ord_dt,14,' '));
    UTL_FILE.put_line(fHandle,v_msg_line);
    end;
    end loop;
    UTL_FILE.put_line(fHandle, '--------------------------------------------------------------------------------------------------------------------------------------------------');
    UTL_FILE.put_line(fHandle, ' Regards : IFSAPP ( Application owner ) ');
    UTL_FILE.FCLOSE(fHandle); ------------writing into file is successfuly done here!
    --Reading of file starts here containt will be added in attchment file
    fHandle :=UTL_FILE.FOPEN('MY_DIRECTORY','pending_pr_summry.txt','R' );
    -- establish the connection to the smtp server
    v_smtp_connection := utl_smtp.open_connection(v_smtp_host, v_smtp_port); /** OPEN CONNECTION ON THE SERVER **/
    -- perform a handshake with the smtp server
    utl_smtp.helo(v_smtp_connection, v_smtp_host); /** DO THE INITIAL HAND SHAKE **/
    -- set the 'from' address of the message
    utl_smtp.mail(v_smtp_connection, v_from);
    -- add the recipient to the message
    utl_smtp.rcpt(v_smtp_connection, v_to);
    -- send the email
    utl_smtp.open_data(v_smtp_connection);
    v_msg_line:='Date: ' || TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' ) || CRLF ||
    'From: ' || v_from || CRLF ||
    'Subject: ' || v_subject || CRLF ||
    'To: ' || v_to || CRLF ||
    'Cc: ' || v_cc || CRLF ||
    'MIME-Version: 1.0'|| CRLF || -- Use MIME mail standard
    'Content-Type: multipart/mixed;'||CRLF ||
    ' boundary="-----SECBOUND"'||CRLF||
    CRLF ||'-------SECBOUND'|| CRLF ||
    'Content-Type: text/plain;'|| CRLF ||
    'Content-Transfer_Encoding: 7bit'|| CRLF ||
    CRLF ||v_body|| CRLF;     -- Message body
    utl_smtp.write_data(v_smtp_connection,v_msg_line);
    v_msg_line:='-------SECBOUND'|| CRLF ||
    'Content-Type: application/octet-stream;'|| CRLF ||
    'Content-Type: text/plain;'|| CRLF ||
    'name="pending_pr_summry.txt"'|| CRLF ||
    'Content-Transfer_Encoding: 8bit'|| CRLF ||
    'Content-Disposition: attachment;'|| CRLF ||
    ' filename="pending_pr_summry.txt"'|| CRLF || CRLF;     -- Content of attachment
    utl_smtp.write_data(v_smtp_connection,v_msg_line);
    -- check file is opened
    IF utl_file.is_open(fHandle) THEN
    -- loop lines in the file
    LOOP
    BEGIN -- Content of attachment
    utl_file.get_line(fHandle,v_msg_line);
    v_msg_line:=concat(v_msg_line,CRLF);
    utl_smtp.write_data(v_smtp_connection,v_msg_line);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
    END LOOP;
    END IF;
    --end of attachment containt     
    utl_smtp.write_data(v_smtp_connection,v_msg_line);
    UTL_FILE.FCLOSE(fHandle);
    utl_smtp.close_data(v_smtp_connection);
    utl_smtp.quit(v_smtp_connection);
    exception
    when utl_smtp.invalid_operation then
    dbms_output.put_line(' Invalid Operation in Mail attempt using UTL_SMTP.');
    when utl_smtp.transient_error then
    dbms_output.put_line(' Temporary e-mail issue - try again');
    when utl_smtp.permanent_error then
    dbms_output.put_line(' Permanent Error Encountered.');
    when others then
    dbms_output.put_line('Exception: SQLCODE=' || SQLCODE || ' SQLERRM=' || SQLERRM);
    RAISE;
    end;
    end bec_file_test;

    Pending PR to process (detail report)01-17-13 12:43:19 PM--------------------------------------------------------------------------------------------------------------------------------------------------Req.no. li Re Site Prj Id Act seq Part no Description Qty UOM want rec dt lat ord dt--------------------------------------------------------------------------------------------------------------------------------------------------MAT/250370 | 2| 1|ISCSP | 4977| 100004207| 0104000016|Angle 50 X 50 X 6 IS:2062 Grade |500|kg |30-NOV-2012| 20-nov-2012MAT/250370 | 3| 1|ISCSP | 4977| 100004207| 0105000002|Channel 100 X 50 IS:2062 Grade A | 1000|kg | 30-NOV-2012| 20-nov-2012MAT/250579 | 2| 1|NMDCJ | 6001| 100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 2991|kg | 13-DEC-2012| 03-dec-2012MAT/250606 | 2| |NMDCJ | 6002| 100005860| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | |1|NMDCJ|6001|100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 1500|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 3| 1|NMDCJ | 6002| 100005818| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 3939|kg | 29-DEC-2012| 19-dec-2012MAT/250606 | 4| 1|NMDCJ | 6002| 100005860| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 39000|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | 4| 1|NMDCJ | 6001| 100005580| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 2| 1|NMDCJ | 6002| 100005818| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 12183|kg | 29-DEC-2012| 19-dec-2012MAT/250606 | 6| 1|NMDCJ | 6002| 100005860| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 9500|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | 6| 1|NMDCJ | 6001| 100005580| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 6| 1|NMDCJ | 6002| 100005818| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | 7| 1|NMDCJ | 6001| 100005580| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 22000|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 7| 1|NMDCJ | 6002| 100005818| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 27060|kg | 29-DEC-2012| 19-dec-2012MAT/251138 | 1| 1|NMDCJ | 6002| 100005825| 3501000001|Cement 50 kg | 1|pkt | 25-DEC-2013| 14-dec-2013--------------------------------------------------------------------------------------------------------------------------------------------------
    where as source file is like that:-
    Pending PR to process (detail report)
    01-17-13 12:43:19 PM
    Req.no. li Re Site Prj Id Act seq Part no Description Qty UOM want rec dt lat ord dt
    MAT/250370 | 2| 1|ISCSP | 4977| 100004207| 0104000016|Angle 50 X 50 X 6 IS:2062 Grade | 5500|kg | 30-NOV-2012| 20-nov-2012
    MAT/250370 | 3| 1|ISCSP | 4977| 100004207| 0105000002|Channel 100 X 50 IS:2062 Grade A | 1000|kg | 30-NOV-2012| 20-nov-2012
    MAT/250579 | 2| 1|NMDCJ | 6001| 100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 2991|kg | 13-DEC-2012| 03-dec-2012
    MAT/250606 | 2| 1|NMDCJ | 6002| 100005860| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250607 | 2| 1|NMDCJ | 6001| 100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 1500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250194 | 3| 1|NMDCJ | 6002| 100005818| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 3939|kg | 29-DEC-2012| 19-dec-2012
    MAT/250606 | 4| 1|NMDCJ | 6002| 100005860| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 39000|kg | 29-DEC-2012| 19-dec-2012
    MAT/250607 | 4| 1|NMDCJ | 6001| 100005580| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250194 | 2| 1|NMDCJ | 6002| 100005818| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 12183|kg | 29-DEC-2012| 19-dec-2012
    MAT/250606 | 6| 1|NMDCJ | 6002| 100005860| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 9500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250607 | 6| 1|NMDCJ | 6001| 100005580| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250194 | 6| 1|NMDCJ | 6002| 100005818| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250607 | 7| 1|NMDCJ | 6001| 100005580| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 22000|kg | 29-DEC-2012| 19-dec-2012
    MAT/250194 | 7| 1|NMDCJ | 6002| 100005818| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 27060|kg | 29-DEC-2012| 19-dec-2012
    MAT/251138 | 1| 1|NMDCJ | 6002| 100005825| 3501000001|Cement 50 kg | 1 |pkt | 25-DEC-2013| 14-dec-2013
    Ignore alignment. It is well formatted in source file.

  • Two line column heading in ALV Report

    Hi Experts,
    My requirement is that I have to create an ALV report with columns having two lines of headings. Like a main heading called Consultants under which 5 to 10 columns of departments(Dept Num, Num of Ppl , Manager etc. ) and then Contractors(Name, Address Etc ) underwhich there would be 5 to 10 departments. Right now my report has the depts of...     
    How can i do that . If u would suggest by CL_SALV_TABLE then it would be great.
    Thanks a lot !
    Sau

    i don't think you can do it using cl_gui_alv_grid or cl_salv_table.

  • SAP Script : to display the material description in two lines

    Hi All,
    I'm working on scripts.
    the material description field is been passed from my driver program ..into the script..
    Ex: &gs_final-maktx& ..
    There r a number of other fields to be displayed ...after this field ....
    Is there any option to split the 'Material description into two lines'?
    Ex: at present it is :
    This is material description
    Requirement is:
    This is material
    description
    I mean that there a number of field berfore and after this field......in the same line
    I need to jst split the materia description ...& make it to appear in two lines.....!!
    Expecting your suggestions....
    Edited by: vidya vidya on Nov 11, 2008 3:17 PM
    Edited by: vidya vidya on Nov 11, 2008 3:20 PM

    FM TEXT_SPLIT ?
    ..but i handled this by code.
    DATA:      zzboldsx(18) TYPE c,
          zzboldsx2(18) TYPE c,
          zzboldsx3(18) TYPE c,
          zzboldsx4(18) TYPE c.
    DATA: i_lines TYPE STANDARD TABLE OF tline WITH HEADER LINE ,
            r_lines TYPE tline,
            v_cnt LIKE sy-tabix.
    CALL FUNCTION 'READ_TEXT'
        EXPORTING
          client                  = sy-mandt
          id                      = stxh-tdid
          language                = stxh-tdspras
          name                    = name
          object                  = stxh-tdobject
        TABLES
          lines                   = i_lines[]
        EXCEPTIONS
          id                      = 1
          language                = 2
          name                    = 3
          not_found               = 4
          object                  = 5
          reference_check         = 6
          wrong_access_to_archive = 7
          OTHERS                  = 8.
      IF sy-subrc = 0.
    * Only 4 lines of Header text supported. Can add if needed
        LOOP AT i_lines INTO r_lines.
          CONDENSE r_lines-tdline NO-GAPS.
          v_cnt = v_cnt + 1.
          CASE v_cnt.
            WHEN 1.
              zzboldsx = r_lines-tdline.
            WHEN 2.
              zzboldsx2 = r_lines-tdline.
            WHEN 3.
              zzboldsx3 = r_lines-tdline.
            WHEN 4.
              zzboldsx4 = r_lines-tdline.
            WHEN OTHERS.
              EXIT.
          ENDCASE.
    *   zzbolDSX =  i_lines-tdline .
        ENDLOOP.

  • Print data in two line in the same column

    Hi,
    In a tabular Report I want to print a column (eg:Description,) in two lines in the same cell.
    Since the description is too long. Is it possible in report 6i. Or any other solution for this?
    Please reply.

    Hello,
    For the Description field set the Vertical Elasticity to EXPAND. Then it will adjust automatically based on data.
    -Ammad

  • Parameter description in two lines

    hi All,
    i need to have a big description for one of the parameter.
    how can i have the description in two line for the same parameter.
    I have use Coment statement for the parameter.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (45) text-002 FOR FIELD p_devatn.
    PARAMETER:  p_devatn(13) TYPE c DEFAULT '0.01'.
    SELECTION-SCREEN END OF LINE.
    kindly  suggest me a way to get the description in two lines.
      Description of parameter             input filed of the parameter
      This is paramerter for                  
      value range
    many thanks,
    Anuj.
    Edited by: Anuj112143 on Nov 24, 2010 4:33 AM

    Hello Anuj ,
      I dont think you can have the description of the parameter  on 2 lines , may be what you can do is to use comment for the 2nd line .
    E.g.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (45) text-001 FOR FIELD p_matnr.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (45) text-002 FOR FIELD p_matnr.
    parameters : p_matnr type mara-matnr.
    SELECTION-SCREEN END OF LINE.
    Regards,
    Arun

  • ALV report : to display description in two lines.

    Hi all,
    In a ALV grid display,  I want to print description(40 characters) of a field in two lines(20 characters in each).
    Please suggest me how to achive the same.
    Thanks in advance.

    make the description field of 20 char legth in your final internal table.
    while passing data to your final internal table, pass all fields along with 20chars from description to one line of final table and in the same loop add another row with all fields blank but the description with rest of the fields..
    loop at it_1 into it_s.
    is_final-desc = it_s-desc+0(20).
    apppend is_fianl to it_final.
    clear is_final.
    is_fianl-desc = it_1-desc+20(20).
    apppend is_fianl to it_final.
    clear it_s.
    endloop.

  • Displaying data in Two line in ALV report

    Hi,
    I want to know how to display the data in alv in two lines for Fild name as well as for fild value
    like in below case
    wa_fieldcata-fieldname  = 'WRBTR'.
       wa_fieldcata-seltext_l  = 'AMOUNT IN DOCUMENT CURRENCY'.
       wa_fieldcata-outputlen  = 18.
       wa_fieldcata-DO_SUM     = 'X'.
       APPEND wa_fieldcata TO it_fieldcat.
       CLEAR wa_fieldcata.
    by this on alv COLUMN headig is coming as 'AMOUNT IN DOCUMENT CURRENCY' in one linw  i want to display  'AMOUNT IN '   in first line and then 'DOCUMENT CURRENCY' below that
    'AMOUNT IN
    DOCUMENT CURRENCY' ***
    similarly how to display value of three fidls in one column
    like for a vendor   I have one column  Vandor name in that column i want to display from table LFA1, 
    NAME1
    NAME2
    NAME3
    NAME4,
    in one column only how to do it.
    regards,
    zafar

    Hi,
    Ref . early reply  can u help me how to uset his in ALV code  and can u give some example for this  how to display it in two lines  as my column heading is of 60 characters 5 word i want to display it in two line in one column only  .
    How to use : SLIS_EV_AFTER_LINE_OUTPUT
    to get this.
    or is there any other method.
    regards,
      zafar

  • How to display two-lines strings item

    Hi,
    How can I display list of two-line string items? Each Item in the list should have a phone number and a time. It should look similar to the "dialled numbers" display where each item has an image, and two-line string.
    Is it possible doing it with the high-level API or should I go low-level?
    Thanks in advance
    Imzadi

    use: list.setFitPolicy(Choice.TEXT_WRAP_ON)

  • File adapter-How to set line break in text file-split record into two lines

    Dear Guru's,
    I have to solve following problem with XML (with mulitiple records) to TEXT file scenario using file adapter. I have to output for ever ONE data record in XML always two identical lines in text file. Second line should have a little bit different mapping in few fields like date,... So I did duplicate fileds in my output structure in mapping and need to know how to set line break in the middle and see half of structure in first line and next structure half in second line
    My output structure in mapping is:
    CASHFLOW
    - INTERFACE
    - GESELLSCHAFT
    - ANWENDUNG
    - PRODUKT
    - VERTRAG
    - BETRAG
    - WAEHRUNG
    - DIRECTION
    - BEWEGUNGSTYP
    - FAELLIGKEIT
    - ZINSFESTSTELLUNG
    - ZAHLUNGSTAG
    - RENDITE
    - INTERFACE2
    - GESELLSCHAFT2
    - ANWENDUNG2
    - PRODUKT2
    - VERTRAG2
    - BETRAG2
    - WAEHRUNG2
    - DIRECTION2
    - BEWEGUNGSTYP2
    - FAELLIGKEIT2
    - ZINSFESTSTELLUNG2
    - ZAHLUNGSTAG2
    - RENDITE2
    Question is how can I set on receiving file adapter in Content Conversion Parameters that fields from first structure half INTERFACE...RENDITE should be outputed in one line and fields from second half of structure INTERFACE2...RENDITE2 should start on second line in final text file.
    I'm getting at the moment one line only and I need to know how can set line break so that second line starting with INTERFACE2(CA)...RENDITE2 will start in new line.
    CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",2,12,2009-01-28,2009-01-27,2009-01-28,"0.0000000",CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",1,10,2009-01-27,2009-01-27,2009-01-27,"0.0000000"
    This should be final output:
    CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",2,12,2009-01-28,2009-01-27,2009-01-28,"0.0000000"
    CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",1,10,2009-01-27,2009-01-27,2009-01-27,"0.0000000"
    My file adapter settings:
    RecordsetStructure=CASHFLOW
    CASHFLOW.fieldNames=INTERFACE,GESELLSCHAFT,ANWENDUNG,PRODUKT,VERTRAG,BETRAG,WAEHRUNG,DIRECTION,BEWEGUNGSTYP,FAELLIGKEIT,ZINSFESTSTELLUNG,ZAHLUNGSTAG,RENDITE
    CASHFLOW.fieldSeparator=,
    CASHFLOW.endSeparator='nl'
    CASHFLOW.fieldNames=INTERFACE2,GESELLSCHAFT2,ANWENDUNG2,PRODUKT2,VERTRAG2,BETRAG2,WAEHRUNG2,DIRECTION2,BEWEGUNGSTYP2,FAELLIGKEIT2,ZINSFESTSTELLUNG2,ZAHLUNGSTAG2,RENDITE2
    CASHFLOW.fieldSeparator=,
    It wont help if I add two identical structures in mapping because in output i would see for multiple entries section with first lines only and after that section with second lines only. And CASHFLOW is one part of more complex mapping ...
    (This is final output structure RecordsetStructure=HEADER,CASHFLOW,CONDITION,REFERENCE,CONTRACT - more sections with different data and all these should have duplicate lines at the end)
    Thanks a lot for any help
    Cheers
    Marian
    Edited by: Marian  Luscon on Jul 14, 2009 11:44 AM

    Hi Ivan,
    right, I did test just for sure.
    Putting constant 'nl' into field CASHFLOW-INTERFACE1 didnt help - still getting one line instead two lines.
    CA ,"0100" ,"7" ,"512" ,20090127GTP101 ,-12454762586.6800 ,"EUR" ,2 ,12 ,2009-01-28 ,2009-01-27 ,2009-01-28 ,"0.0000000" ,'nl' ,"GTP1" ,"7" ,"512" ,20090127GTP101 ,-12454762586.6800 ,"EUR" ,1 ,10 ,2009-01-27 ,2009-01-27 ,2009-01-27 ,"0.0000000"
    So there is still question. Is there any way (mapping,...) how to output always 2 lines in text file for one record in XML. It always does 1 record in mapping structure = 1 line but we need 2 lines ...
    Example:
    Input: 4 records in XML
    Output: 8 lines in final text file ...
    Thanks to you all guys
    Marian

Maybe you are looking for

  • MS Access Web App: corrupted table, cannot open in Access anymore

    **tldr: How can I delete a corrupted table that prevents me from opening my Web App in Access?** I used the Access desktop client to create a new table with approx 20 lookup fields. When I tried saving the table, I received an error message about too

  • I am trying to sync my iphone and it has frozen with the itunes symbol on my phone?

    I am trying to sync my iphone and it looks like it has crashed and the itunes symbol is frozen on my screen, I have tried to switch off my phone but it will not work, anyone help?

  • 24'' iMac SuperDrive Problem

    I have a problem with my iMac's SuperDrive. I have a DVD recorder for my TV, and I recorded a movie to a DVD-R. When I insert the DVD into the iMac, the drive spins for a long time, then mounts an empty CDR onto the desktop. I have no idea what's goi

  • New to Java cant get it to compile in msDOS

    Using SDK java 2 version 1.4.0. Checked my personal Computer folder types. In folders in windows 98 do java file types open with javac.exe or java.exe? Tried both. When I try to compile a simple tutorial HelloWorldApp.java , it gives me a message tha

  • NoMatchingActionMethodException error when extending class

    I have a base class (BaseProcess) that extends the PageFlowController. This class has an instance of a form: ,FSFormBean. I also have an action method that uses this form: * @jpf:action * @jpf:forward name="success" path="../hub/HubController.jpf" pu