How to do the multiple-line String at JList?
hey everyone,
i want to create a JList have to display multiple-line string.
i have use String a="text1"+"\n"+"text2" inside my JList...
the "\n" change to a sequare box...
how cum like that.................??
i need ur kindly helping...
Because the default renderer for a JList element is a
JLabel, and that is how JLabel behaves. The question
"how to do a multiple-line JLabel" has been asked
hundreds of times in this forum, search for that.i have search for it already but i no get it..anything!
so, can u give me the url for me? thank you!
Similar Messages
-
How to do the multiple-line String at JList? help!
i need some code to multiple-line String at JList.
i know that it is can be done by html code.
example:
<p>line1</p><p>line2</p>
but if i use that html code...
i face another problem to my JList..
it cannot set the font use the ListCellRenderer..
like:
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
Color newColor = new Color(230, 230, 230);
setIcon(((DisplayItem)value).getIcon());
setText(((DisplayItem)value).getChat());
setFont(((DisplayItem)value).getFont());
setBackground(isSelected ? newColor : Color.white);
setForeground(isSelected ? Color.black : Color.black);
if (isSelected) {
setBorder(
BorderFactory.createLineBorder(
Color.red, 2));
} else {
setBorder(
BorderFactory.createLineBorder(
list.getBackground(), 2));
return this;
all my JList will be html type...
i don't want that happen..can be another method to do that multiple-line String in JList??
i also need to set a icon image between string in the JList. anyone get idea??
i need ur help!
thank you.I think you should create/override several methods like setText(String), setIcons(Icon[]), paintComponent(Graphics), getMinimumSize(), getPreferredSize(), etc.
I would like to code like below...:class MultilineLabel extends JLabel {
private String[] text = null;
private ImageIcon[] icons = null;
public void setText( String newText ) {
// It overrides JLabel.setText( String )
// Tokenize newText with line-separator
// and put each text into the 'text' array.
public void setIcons( Icon[] newIcon ) {
// It is similar to JLabel.setIcon( Icon ) method,
// but it receives an array of Icon-s. Set these icons to 'icons' variable.
public void paintComponent( Graphics g ) {
// It overrides JComponent.paintComponent( Graphics ) method.
super.paintComponent( g );
if ( text != null && icons != null ) {
int icon_x = 0;
int text_x = 0;
int y = 0;
// draw customized content..
for ( int i=0; i<text.length; i++ ) {
// compute x and y locations
// icon_x = ...
// text_x = ...
// y = ...
// and draw it!
g.drawString( text[ i ], text_x, y );
icon[ i ].paintIcon( this, g, icon_x, y );
public Dimension getMinimumSize() {
int width = super.getMinimumSize().width;
int height = ... // I think you must compute it with 'text' and 'icons'' arrays.
return new Dimension( width, height );
public Dimension getPreferredSize() {
int width = super.getPreferredSize().width;
int height = ...
return new Dimension( width, height );
}I think that code-structure above is the minimum to implement your requirements. (Of course if you want to implement it :)
Good luck and let me know it works or not. :) -
How to handle the multiple line items in the Inbound idoc FM
Hi ,
Can any body give me how to handle the multiple line item in the idoc when we reprocessing it from workitem....
Thanks in Advance,,,,
Regards,
BharaniHi ,
Can any body give me how to handle the multiple line item in the idoc when we reprocessing it from workitem....
Thanks in Advance,,,,
Regards,
Bharani -
How to display the multiple lines text in a single - String, StringBuffer
Hi,
I have a textarea field named Decription which contains more than one line seperated by new line.I need to display those five lines in a single text without breaking. Is it possible? I am getting ArrayIndexOutOfBoundsException while i reached to the end of the line. Plz help me how to align the below code so that i can display the lines as a single line in my excel sheet.
if(op.getDescription()!=null)
String[] oppDescs = op.getDescription().split("\n");
StringBuffer sb = new StringBuffer();
for(int i1=0; i<=oppDescs.length-1;++i1)
*writeFile(sb.append(oppDescs[i1]), valueWriter);*
} else {
writeFile(op.getDescription(), valueWriter);
private void writeFile(java.lang.Object value,PrintWriter valueWriter)
if(value!=null)
valueWriter.print(value);
}Thanks and Regardsprevious was java1.5
heres a 1.1 - 1.4 version
String[] oppDescs = op.getDescription().split("\n");
StringBuffer sb = new StringBuffer();
for(int i = 0; i < oppDescs.length : i++){
sb.append(oppDescs);
sb.append( '\t' );
writeFile(sb.toString(), valueWriter );Edited by: simon_orange on 31-Oct-2008 13:02 -
How to get the multiple lines on the header part in ALV
HI all,
In my program i am using the ALV- Grid functionality through methods. I have 2 different layouts in the same screen , for this i have 2 containers and i am displaying the title through the gird title now i need to add the few more lines under the title .
Please suggest me, how can i proceede now.
Thanks
GiridharHi,
check this sample code, i did it using splitter container. check it, it is weel documented to know what are required ....
REPORT ZTEST_ALV_TOP MESSAGE-ID ZZ .
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_VALID TYPE C,
V_FLAG,
V_DATA_CHANGE,
V_ROW TYPE LVC_S_ROW,
V_COLUMN TYPE LVC_S_COL,
V_ROW_NUM TYPE LVC_S_ROID.
DATA: IT_ROW_NO TYPE LVC_T_ROID,
X_ROW_NO TYPE LVC_S_ROID.
DATA:BEGIN OF ITAB OCCURS 0,
VBELN LIKE LIKP-VBELN,
POSNR LIKE LIPS-POSNR,
CELLCOLOR TYPE LVC_T_SCOL, "required for color
DROP(10),
END OF ITAB.
"The Below Definitions Must.....
DATA:
* Reference to document
DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT,
* Reference to split container
DG_SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
* Reference to grid container
DG_PARENT_GRID TYPE REF TO CL_GUI_CONTAINER,
* Reference to html container
DG_HTML_CNTRL TYPE REF TO CL_GUI_HTML_VIEWER,
* Reference to html container
DG_PARENT_HTML TYPE REF TO CL_GUI_CONTAINER.
"up to here
* CLASS lcl_event_handler DEFINITION
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
**Hot spot Handler
HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
**Double Click Handler
HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN ES_ROW_NO,
TOP_OF_PAGE FOR EVENT TOP_OF_PAGE "event handler
OF CL_GUI_ALV_GRID
IMPORTING E_DYNDOC_ID.
* END_OF_LIST FOR EVENT end_of_list "event handler
* OF CL_GUI_ALV_GRID
* IMPORTING E_DYNDOC_ID.
ENDCLASS. "lcl_event_handler DEFINITION
* CLASS lcl_event_handler IMPLEMENTATION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
*Handle Hotspot Click
METHOD HANDLE_HOTSPOT_CLICK .
CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
V_ROW = E_ROW_ID.
V_COLUMN = E_COLUMN_ID.
V_ROW_NUM = ES_ROW_NO.
* MESSAGE I000 WITH V_ROW 'clicked'.
CLEAR IT_ROW_NO[].
X_ROW_NO-ROW_ID = V_ROW.
APPEND X_ROW_NO TO IT_ROW_NO .
CALL METHOD G_GRID->SET_SELECTED_ROWS
EXPORTING
IT_ROW_NO = IT_ROW_NO.
ENDMETHOD. "lcl_event_handler
*Handle Double Click
METHOD HANDLE_DOUBLE_CLICK.
CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
V_ROW = E_ROW.
V_COLUMN = E_COLUMN.
V_ROW_NUM = ES_ROW_NO.
IF E_COLUMN = 'VBELN'.
SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
ENDIF.
IF E_COLUMN = 'POSNR'.
SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN."
ENDIF.
ENDMETHOD. "handle_double_click
* METHOD END_OF_LIST. "implementation
** Top-of-page event
* PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
* ENDMETHOD. "top_of_page
METHOD TOP_OF_PAGE. "implementation
* Top-of-page event
PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
ENDMETHOD. "top_of_page
ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION
*& Global Definitions
DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM,
G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
GS_LAYOUT TYPE LVC_S_LAYO.
data: v_lines type i.
data: v_line(3) type c.
*- Fieldcatalog for First and second Report
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
X_FIELDCAT TYPE LVC_S_FCAT,
LS_VARI TYPE DISVARIANT.
* START-OF_SELECTION
START-OF-SELECTION.
SELECT VBELN
POSNR
FROM LIPS
UP TO 20 ROWS
INTO CORRESPONDING FIELDS OF TABLE ITAB.
describe table itab lines v_lines.
END-OF-SELECTION.
IF NOT ITAB[] IS INITIAL.
CALL SCREEN 100.
ELSE.
MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
ENDIF.
*& Form CREATE_AND_INIT_ALV
* text
FORM CREATE_AND_INIT_ALV .
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
"attention.....from here
"split your container here...into two parts
"create the container
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = G_CONTAINER1.
"this is for top of page
* Create TOP-Document
CREATE OBJECT DG_DYNDOC_ID
EXPORTING STYLE = 'ALV_GRID'.
* Create Splitter for custom_container
CREATE OBJECT DG_SPLITTER
EXPORTING PARENT = G_CUSTOM_CONTAINER
ROWS = 2
COLUMNS = 1.
* Split the custom_container to two containers and move the reference
* to receiving containers g_parent_html and g_parent_grid
"i am allocating the space for grid and top of page
CALL METHOD DG_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = DG_PARENT_HTML.
CALL METHOD DG_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 2
COLUMN = 1
RECEIVING
CONTAINER = DG_PARENT_GRID.
* CALL METHOD DG_SPLITTER->GET_CONTAINER
* EXPORTING
* ROW = 2
* COLUMN = 1
* RECEIVING
* CONTAINER = DG_PARENT_HTML.
* CALL METHOD DG_SPLITTER->GET_CONTAINER
* EXPORTING
* ROW = 1
* COLUMN = 1
* RECEIVING
* CONTAINER = DG_PARENT_GRID.
"you can set the height of it
* Set height for g_parent_html
CALL METHOD DG_SPLITTER->SET_ROW_HEIGHT
EXPORTING
ID = 1
HEIGHT = 5.
"from here as usual..you need to specify parent as splitter part
"which we alloted for grid
CREATE OBJECT G_GRID
EXPORTING I_PARENT = DG_PARENT_GRID.
* Set a titlebar for the grid control
CLEAR GS_LAYOUT.
GS_LAYOUT-GRID_TITLE = TEXT-003.
GS_LAYOUT-ZEBRA = SPACE.
GS_LAYOUT-CWIDTH_OPT = 'X'.
GS_LAYOUT-NO_ROWMARK = 'X'.
GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
CALL METHOD G_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
CREATE OBJECT G_HANDLER.
SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
* SET HANDLER G_HANDLER->END_OF_LIST FOR G_GRID.
SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.
DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
DATA: L_INDEX TYPE SY-TABIX.
"Here i am changing the color of line 1,5,10...
"so you can change the color of font conditionally
LOOP AT ITAB.
L_INDEX = SY-TABIX.
IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '0'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
LS_CELLCOLOR-FNAME = 'POSNR'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '0'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
ENDIF.
ENDLOOP.
* setting focus for created grid control
CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
EXPORTING
CONTROL = G_GRID.
* Build fieldcat and set editable for date and reason code
* edit enabled. Assign a handle for the dropdown listbox.
PERFORM BUILD_FIELDCAT.
PERFORM SET_DRDN_TABLE.
* Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
**Vaiant to save the layout
LS_VARI-REPORT = SY-REPID.
LS_VARI-HANDLE = SPACE.
LS_VARI-LOG_GROUP = SPACE.
LS_VARI-USERNAME = SPACE.
LS_VARI-VARIANT = SPACE.
LS_VARI-TEXT = SPACE.
LS_VARI-DEPENDVARS = SPACE.
**Calling the Method for ALV output
CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
IS_VARIANT = LS_VARI
IS_LAYOUT = GS_LAYOUT
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = IT_FIELDCAT
IT_OUTTAB = ITAB[].
"do these..{
* Initializing document
CALL METHOD DG_DYNDOC_ID->INITIALIZE_DOCUMENT.
* Processing events
CALL METHOD G_GRID->LIST_PROCESSING_EVENTS
EXPORTING
I_EVENT_NAME = 'TOP_OF_PAGE'
I_DYNDOC_ID = DG_DYNDOC_ID.
"end }
* Set editable cells to ready for input initially
CALL METHOD G_GRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form EXCLUDE_TB_FUNCTIONS
* text
* -->PT_EXCLUDE text
FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
* Only allow to change data not to create new entries (exclude
* generic functions).
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form build_fieldcat
* Fieldcatalog
FORM BUILD_FIELDCAT .
DATA: L_POS TYPE I.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-NO_ZERO = 'X'.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-HOTSPOT = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Item'(025).
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
X_FIELDCAT-FIELDNAME = 'DROP'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-DRDN_HNDL = '1'.
X_FIELDCAT-DRDN_ALIAS = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
ENDFORM. " build_fieldcat
*& Module STATUS_0100 OUTPUT
* text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF G_CUSTOM_CONTAINER IS INITIAL.
**Initializing the grid and calling the fm to Display the O/P
PERFORM CREATE_AND_INIT_ALV.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form SET_DRDN_TABLE
* text
FORM SET_DRDN_TABLE.
DATA:LT_DRAL TYPE LVC_T_DRAL,
LS_DRAL TYPE LVC_S_DRAL.
LOOP AT ITAB .
* First listbox (handle '1').
IF SY-INDEX = 1.
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = ' '.
LS_DRAL-INT_VALUE = ' '.
ELSE.
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = ITAB-POSNR.
LS_DRAL-INT_VALUE = ITAB-POSNR.
ENDIF.
APPEND LS_DRAL TO LT_DRAL.
ENDLOOP.
**Setting the Drop down table for Reason Code
CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
EXPORTING
IT_DROP_DOWN_ALIAS = LT_DRAL.
ENDFORM. " set_drdn_table
*& Form EVENT_TOP_OF_PAGE
* text
* -->DG_DYNDOC_ID text
FORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.
"this is more clear.....check it
"first add text, then pass it to comentry write fm
DATA : DL_TEXT(255) TYPE C. "Text
* Populating header to top-of-page
CALL METHOD DG_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = 'Test Report'
SAP_STYLE = CL_DD_AREA=>HEADING.
* Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
* Move program ID
CONCATENATE 'Program Name :' SY-REPID
INTO DL_TEXT SEPARATED BY SPACE.
* Add Program Name to Document
PERFORM ADD_TEXT USING DL_TEXT.
* Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
* Move User ID
CONCATENATE 'User ID :' SY-UNAME INTO DL_TEXT SEPARATED BY SPACE
* Add User ID to Document
PERFORM ADD_TEXT USING DL_TEXT.
* Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
* Move count (no of records).
move v_lines to v_line.
CONCATENATE 'No of records :' v_line INTO DL_TEXT SEPARATED BY SPACE.
* Add Client to Document
PERFORM ADD_TEXT USING DL_TEXT.
* Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
* Move date
WRITE SY-DATUM TO DL_TEXT.
CONCATENATE 'Date :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.
* Add Date to Document
PERFORM ADD_TEXT USING DL_TEXT.
* Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
* Move time
WRITE SY-UZEIT TO DL_TEXT.
CONCATENATE 'Time :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.
* Add Time to Document
PERFORM ADD_TEXT USING DL_TEXT.
* Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
* Populating data to html control
PERFORM HTML.
ENDFORM. " EVENT_TOP_OF_PAGE
*& Form ADD_TEXT
* To add Text
FORM ADD_TEXT USING P_TEXT TYPE SDYDO_TEXT_ELEMENT.
* Adding text
CALL METHOD DG_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = P_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING.
ENDFORM. " ADD_TEXT
*& Form HTML
* text
FORM HTML.
DATA : DL_LENGTH TYPE I, " Length
DL_BACKGROUND_ID TYPE SDYDO_KEY VALUE SPACE. " Background_id
* Creating html control
IF DG_HTML_CNTRL IS INITIAL.
CREATE OBJECT DG_HTML_CNTRL
EXPORTING
PARENT = DG_PARENT_HTML.
ENDIF.
* Reuse_alv_grid_commentary_set
CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
EXPORTING
DOCUMENT = DG_DYNDOC_ID
BOTTOM = SPACE
IMPORTING
LENGTH = DL_LENGTH.
* Get TOP->HTML_TABLE ready
CALL METHOD DG_DYNDOC_ID->MERGE_DOCUMENT.
* Set wallpaper
CALL METHOD DG_DYNDOC_ID->SET_DOCUMENT_BACKGROUND
EXPORTING
PICTURE_ID = DL_BACKGROUND_ID.
* Connect TOP document to HTML-Control
DG_DYNDOC_ID->HTML_CONTROL = DG_HTML_CNTRL.
* Display TOP document
CALL METHOD DG_DYNDOC_ID->DISPLAY_DOCUMENT
EXPORTING
REUSE_CONTROL = 'X'
PARENT = DG_PARENT_HTML
EXCEPTIONS
HTML_DISPLAY_ERROR = 1.
IF SY-SUBRC NE 0.
MESSAGE I999 WITH 'Error in displaying top-of-page'(036).
ENDIF.
ENDFORM. " HTML
Regards
vijay -
How to create a multiple-line TextBox in a jfx script?
How to create a multiple-line TextBox in a jfx script?
Or
How to use the Swing component JTextArea in a jfx script?
Please post a brief code segment.
Thanks,
AsgharThis supports two way binding between JavaFX and Java and also cut and paste.
Enjoy.
* MyTextArea.fx
* Created on Dec 14, 2008, 7:23:49 AM
package twifxer.components;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.Font;
import javafx.ext.swing.SwingComponent;
import javax.swing.JComponent;
import javax.swing.JTextArea;
import java.awt.Color;
* @author Steven Herod
public class TweetTextComponent extends SwingComponent{
var myComponent: JTextArea;
public var length: Integer;
public var readText:String;
public var text: String on replace{
myComponent.setText(text);
public var toolTipText: String on replace{
myComponent.setToolTipText(toolTipText);
public override function createJComponent():JComponent{
translateX = 15;
translateY = 5;
var f:Font = new Font("sanserif",Font.PLAIN, 11);
myComponent = new JTextArea(4, 33);
myComponent.setOpaque(false);
myComponent.setFont(f);
myComponent.setWrapStyleWord(true);
myComponent.setLineWrap(true);
myComponent.addKeyListener( KeyListener{
public override function
keyPressed(keyEvent:KeyEvent) {
if (keyEvent.VK_PASTE == keyEvent.getKeyCode())
myComponent.paste();
public override function
keyReleased( keyEvent:KeyEvent) {
var pos = myComponent.getCaretPosition();
text = myComponent.getText();
myComponent.setCaretPosition(pos);
public override function
keyTyped(keyEvent:KeyEvent) {
length = myComponent.getDocument().getLength();
return myComponent;
} -
How to delete the logical lines in JTextArea
Hi all,
Now that I know how to find the logical line count in JTextArea as
I found the following in the forum.
public static int getLineCount (JTextArea _textArea)
boolean lineWrapHolder = _textArea.getLineWrap();
_textArea.setLineWrap(false);
double height = _textArea.getPreferredSize().getHeight();
_textArea.setLineWrap(lineWrapHolder);
double rowSize = height/_textArea.getLineCount();
return (int) (_textArea.getPreferredSize().getHeight() / rowSize);
I want to delete the 4th line to the last line and append ... at the 4th, if the getLineCount exceeds 3. Does any body know how to do so?
The intention is for the multiline tooltip as I just want to show
the first three logical line and ... if the string is too long.
Thanks
PinThe code looks good to me. The only thought I have is that the y coordinate for the rowThree point is wrong and is referencing row four.
I've been playing around with using a JTextArea as a renderer for a JTable. I have it working so that "..." appear when the text exceeds 2 rows. Try clicking on "B" in the letter column and then the update cell button a few times to add text. My code is slightly different than yours.
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
public class TestTable extends JFrame
private final static String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
JTable table;
Vector row;
public TestTable()
Object[][] data = { {"1", "A"}, {"2", "B"}, {"3", "C"} };
String[] columnNames = {"Number","Letter"};
DefaultTableModel model = new DefaultTableModel(data, columnNames);
table = new JTable(model)
public String getToolTipText( MouseEvent e )
int row = rowAtPoint( e.getPoint() );
int column = columnAtPoint( e.getPoint() );
if (row == 0)
return null;
else
return row + " : " + column;
table.setRowSelectionInterval(0, 0);
table.setColumnSelectionInterval(0, 0);
table.setRowHeight(0,34);
table.setRowHeight(1,34);
table.setRowHeight(2,34);
table.setDefaultRenderer(Object.class, new TextAreaRenderer(2));
JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add( scrollPane );
JPanel buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
JButton button2 = new JButton( "Update Cell" );
buttonPanel.add( button2 );
button2.addActionListener( new ActionListener()
public void actionPerformed(ActionEvent e)
int row = table.getSelectedRow();
int column = table.getSelectedColumn();
String value = (String)table.getValueAt(row, column);
value += value;
table.setValueAt( value, row, column );
DefaultTableModel model = (DefaultTableModel)table.getModel();
model.fireTableCellUpdated(row, column);
table.requestFocus();
public static void main(String[] args)
TestTable frame = new TestTable();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setVisible(true);
private class TextAreaRenderer extends JTextArea implements TableCellRenderer
public TextAreaRenderer(int displayRows)
setRows(displayRows);
setLineWrap( true );
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
setText( value.toString() );
Dimension d = getPreferredSize();
int maximumHeight = getRows() * getRowHeight();
if (d.height > maximumHeight)
setSize(d);
int offset = viewToModel( new Point(d.width, maximumHeight - 1) );
replaceRange( "...", offset-3, getDocument().getLength() );
return this;
} -
How to delete the specified line in file?
How to delete the specified line in file? In case of deleting a specified line in a file, how to do?
Line 1
Line 2
Line 3
Line 4
Line 5
The case is a file including the above content. Now I wanna to delete the "Line 3" and how to realize the action in Java?An alternative solution can be :
import java.io.LineNumberReader;
import java.io.IOException;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;
public class LineDeleter {
public static void main(String args[]){
try {
//suppose you want to delete line 3
int lineToBeDeleted = 3;
File f = new File("line.txt");
long fileSize = f.length();
//Wrap the FileReader with a LineNumberReader. It will help you
//identify the lines.
LineNumberReader lnr = new LineNumberReader( new FileReader(f));
//Wrap the FileWriter object with BufferedWriter object. Create it with the buffersize
//equal to the file size.
BufferedWriter bw = new BufferedWriter(new FileWriter(new File("line1.txt")),(int)fileSize);
//Wrap BufferedWriter object with PrintWriter so that it allows you
//to print line by line
PrintWriter pw = new PrintWriter(bw);
String s=null;
while ( (s=lnr.readLine())!=null ){
System.out.println(s);
int lineNumber = lnr.getLineNumber();
//match the line number
if(! (lineNumber==lineToBeDeleted)){
pw.println(s);
pw.flush();
lnr.close();
pw.close();
catch(Exception e){System.out.println(e);}
If you want you can rename the line1.txt to the original file name.
I hope this helps.Good luck!!!!!! -
How to make the diagonal line in the swing table cell?
Hi all,
How to make the diagonal line in the swing table cell just like the link below?
http://61.132.17.188/webber/table.gifOne improvement.. To get a line that is neat, use a bit of Graphics2D
public void paintComponent(java.awt.Graphics g)
int w = getSize().width;
int h = getSize().height;
// draw a line between (0,0) and (w,h)
g.setColor(getForeground());
if (strTop == null)
strTop = " ";
if (strBottom == null)
strBottom = " ";
java.awt.Graphics2D g2 = (java.awt.Graphics2D)g;
g2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING,java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
//g2.setStroke(new java.awt.BasicStroke(14.0f));
g.drawLine(0, 0, w, h);
//the following lines will draw the two strings,
//one above the top of the line and the above below it.
g2.drawString(strTop, (w/2)+2, (h/2)-2);
g2.drawString(strBottom, 2, (h / 2) + 2);
//the x,y for drawString are only based on assumption. //do necessary changes to suit ur needs.
}Then create a TableCellRenderer and set it to the Table Header for ur table's 1st row.....
Cheers -
How to break the command line in SAP scripts
Hi,
Can any one Please guide me how to continue the command line( /: ) of SAP SCPRIPT into multiple lines.
Regards
KiranHi Kiran,
U can continue in the same line itself by pressing SHIFT+F8
If u want it in the next line then u can give space in the tag column.
Thanks,
Vinod. -
Itunes - how do i select multiple line items not in sequence ?
itunes - how do i select multiple line items not in sequence ?
Hold down the Command key and click each in succession.
To extend the selection across items that ARE contiguous, use the Shift key. -
How to echo the first line???
Hi everybody,
I need to know how to echo the first line of an XML document with a SAX parser, for example :
<?xml version="1.0"?>I've already tried :
public void processingInstruction(String target, String data) throws SAXException {
System.out.println("Target = (" + target + ")");
System.out.println("Data = (" + data + ")");
}but it doesn't work.
Please, help me...
Thanks.
Maxime.http://java.sun.com/webservices/docs/1.0/tutorial/doc/JAXPSAX4.html
-
How To Parse The Command Line?
Hello,dear. When I writing a C/S mode application,which performing download and upload files between the FTP server and the clients, I encountered the problem of parsing the command line.
I intend to download file from the server side ,using this following format ,which is composed by four arguments:
ftp>receive server's IPaddress portnumber filename
The problem is I don't know how to parse the command line and store them to some objects and using it.
I'm right here waiting for the nice problem-shooter.
Thanks for reading my poor expression.In your console application main class
public static void main(String[] args)
// code
args is a sting array with the command
line itemsI think you missed the point or forgot the ":-)". This is the "Socket", not the "New to Java" forum. -
How to capture the multiple value in list box
Hi forums,
How to select the multiple values in list box and how to catch that values in OnInputProcessing.
Regards,
Ravi.Hi,
A possible method is:
Get all fields of the form
CALL METHOD request->get_form_fields
CHANGING
fields = table_fields.
loop over the fields
LOOP AT table_fields INTO wa_fields.
test the name of the field
CASE wa_fields-name.
WHEN 'test'.
retrieve the value of the field
test = wa_fields-value.
endcase
endloop.
Eddy -
How to get the value of String in integer type
how to get the value of String in integer
{color:#0000ff}http://java.sun.com/javase/6/docs/api/java/lang/Integer.html#parseInt(java.lang.String)
http://java.sun.com/javase/6/docs/api/java/lang/Integer.html#valueOf(java.lang.String){color}
Maybe you are looking for
-
The error i m getting is emsg:was terminated by signal 11
Hi.. when i m running a customized invoice printing xml report through a concurrent program i am getting the error that emsg:was terminated by signal 11 Starting concurrent program execution... +----------------------------- Arguments p_order_by='TRX
-
Restrict authorization for saving BI query bookmark on BEx Portfolio
Hi experts, I would like to find a way to control the saving query bookmark functionality on BEx Portfolio. The problem is that every BI user can save in the BEx Portfolio which is observable to every user at global level. Is there a functionality t
-
Color Balancing both incandescent and daylight in interior photos?
I take many architectural photos around sunset, so I get a mix of dayllight and incandescent in the interior photos. I can easily set the white balance to correct one area, but I'm looking for a way to adjust the other area(s). I think an adjustmen
-
IPHONE 6 Missed Calls Alerts???
In Iphone 6 or in IOS 8, Is there any option to have missed calls alerts like message alerts? Also it has alert battery is full charged? MA
-
Hi how can i sort a trnsparent table. Regards Arun