How to set selected text on JTextPane ?

I need to set selected text on a JTextPane. I used setSelectionStart(); and setSelectionEnd(); but it doesn't work.
Can anybody help me?

I'm not sure if this is what you are looking for, but the following code sample was revised from the tutorial TextSamplerDemo.java. It will hightlight the word "selected" in yellow in the JTextPane.
//created with j2sdk1.4.0_01
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;      
public class SelectedText extends JFrame {
    public SelectedText() {
        super("Selected Text");       
        //Create a text pane.
        JTextPane textPane = createTextPane();
        JScrollPane paneScrollPane = new JScrollPane(textPane);
        paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        paneScrollPane.setPreferredSize(new Dimension(250, 155));
        paneScrollPane.setMinimumSize(new Dimension(10, 10));
        Container pane = getContentPane();
        pane.add(paneScrollPane);
    private JTextPane createTextPane() {
        JTextPane textPane = new JTextPane();
        String[] initString =
                { "This is the ", //regular
                  "selected",     //selected
                  " text. "       //regular
        String[] initStyles = {"regular", "selected", "regular"};
        initStylesForTextPane(textPane);
        Document doc = textPane.getDocument();
        try {
            for (int i=0; i < initString.length; i++) {
                doc.insertString(doc.getLength(), initString,
textPane.getStyle(initStyles[i]));
} catch (BadLocationException ble) {
System.err.println("Couldn't insert initial text.");
return textPane;
protected void initStylesForTextPane(JTextPane textPane) {
//Initialize some styles.
Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
Style regular = textPane.addStyle("regular", def);
StyleConstants.setFontFamily(def, "SansSerif");
Style s = textPane.addStyle("selected", regular);
StyleConstants.setBackground(s, Color.YELLOW);
public static void main(String[] args) {
JFrame frame = new SelectedText();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
frame.pack();
frame.setVisible(true);
S.L.

Similar Messages

  • How to set selected text color in Spark TextInput

    I'm trying to make Spark TextInputs and MXFTETextInputs look like Halo/MX TextInputs as much as possible, since I have a mix of both Spark and MX TextInputs in my application. I know I can set the
    selection background color to black using focusedTextSelectionColor. How can I set the selected text color to white so it matches the MX white-on-black look?

    This works, if you set the enabled property directly on the s:TextInput:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx">
        <s:layout>
            <s:VerticalLayout horizontalAlign="center" verticalAlign="middle" />
        </s:layout>
        <s:controlBarContent>
            <s:CheckBox id="ch" label="enabled" selected="true" />
        </s:controlBarContent>
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            @namespace mx "library://ns.adobe.com/flex/mx";
            s|TextInput:disabled {
                color: red;
        </fx:Style>
        <s:Group>
            <s:TextInput id="ti" text="The quick brown fox jumps over the lazy dog" enabled="{ch.selected}" />
        </s:Group>
    </s:Application>
    It can get a bit trickier when you're setting the enabled property on a parent container, since (I believe) that the child control's enabled properties are still set to true and just the container is disabled. One possible workaround would be to bind the child TextInput control's enabled property to the container's enabled property. That way the s:TextInput should still go to it's disabled state and you can customize the disabled state's styles to have darker text, or whatever else you want.
    <s:Group id="gr" enabled="{ch.selected}">
        <s:TextInput id="ti" text="The quick brown fox jumps over the lazy dog" enabled="{gr.enabled}" />
    </s:Group>
    Peter

  • How can i Change the Size of the selected text in JTextPane using ConboBox

    plzz help...
    How can i Change the Size of the selected text in JTextPane using ConboBox ???
    i m using if(cb.getSelectedItem=="small")
    cb.setAction(new StyledEditorKit.FontSizeAction("double click", 12);)
    if(cb.getSelectedItem=="medium")
    cb.setAction(new StyledEditorKit.FontSizeAction("double click", 14);)
    if(cb.getSelectedItem=="large")
    cb.setAction(new StyledEditorKit.FontSizeAction("double click", 16);)
    this code is not working properly according to the action i set on comboBox.
    when i select medium the previously set action on comboBox works like small action work.
    when i select large the medium action starts .
    means its not working in correct time when i select item of combox n action of that item is not working at that time..
    plzz plzz help me:(

    Action action1 = new StyledEditorKit.FontSizeAction(
    "double click", 12);
    Action action2 = new StyledEditorKit.FontSizeAction(
    "double click", 14);
    Action action3 = new StyledEditorKit.FontSizeAction(
    "double click", 18);
    s2 = (String) cb7.getSelectedItem();
    if (s2.equals("Small")) {
    cb7.setAction(action1);
    e1.setSource(cb7);
    } else
    if (s2.equals("Medium")) {
    cb7.setAction(action2);
    e1.setSource(cb7);
    } else if (s2.equals("Large")) {
    cb7.setAction(action3);
    // e1.setSource(cb7);
    when i chooze any combobox item then according to that item i set the Action on ComboBox but that action is not working properly on the selected text in the JTextPane..means selected text in JText Pane is not changes its Size according to the comboBox selected ITEM.
    PLZ plzzzzzzzzzz help me:((.i will be thankfull to u.

  • How to programatically select text for editing in an af:inputText control?

    Hello, I am new to jdeveloper 11.1.1.3.0 and have searched and searched for info. I must be using the wrong terms as I cannot find any info or example on how to programatically select text for editing in an inputText field.
    My request is to change an existing app so when the user presses a button, control should go to the inputText control (this part works, see existing backing bean code from another developer below) but automatically select the text within for editing by the user (saving the user from having to select the text first before editing).
    Backing bean code to set the focus to an inputText field:
    * sets the cursor to the given component id
    * @param  componentId of item on page
      public void setFocusOnUIComponent(String componentId) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExtendedRenderKitService service =
          Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);
        UIComponent uiComponent = facesContext.getViewRoot().findComponent(componentId);
        service.addScript(facesContext,
          "Component = AdfPage.PAGE.findComponentByAbsoluteId('" + componentId + "'); Component.focus();");
      } I hope this isn't a dumb question and would appreciate it if someone can steer me in the right direction.
    Thank you for any info,
    Gary

    Hi,
    not a dumb question at all. Before answering it, here some comments on the code you pasted in your question
    1. UIComponent uiComponent = facesContext.getViewRoot().findComponent(componentId);
    This code line is not used at all in your method. So it seems you can get rid of it
    2. "Component = AdfPage.PAGE.findComponentByAbsoluteId('" + componentId + "'); Component.focus();");
    I suggest to change it to
    "var component = AdfPage.PAGE.findComponentByAbsoluteId('" + componentId + "'); component.focus();");
    as it is better coding practice to have variable names starting with a lower case letter and being flagged with the "var" identifier
    For pre-selecting text in an an input component, there is no API available in ADF Faces, which means you need to reach out to the rendered HTML ouput. To access the markup for the rendered component, you can try
    var markup = AdfRichUIPeer.getDomContentElementForComponent(component)
    If this markup returns the HTML input component then you can use JavaScript you find on the Internet to select the area of it. If it does not return the input component then you may have to use
    document.getElementById(componentId+'::content')
    Note however that working directly with generated HTML output bears the risk that your code breaks when - for whatever reason - the ADF Faces component rendering changes in the future
    Frank
    Frank

  • How to set selected radioButton

    Hi,
    There are tons of examples on the websites to show you how to detect selected radioButton or click event. But It is not easy to find aone example to show you how to set selected radioButton.
    Here is my code, but not working, Is it not well handle on it for Flex?
    [Bindable]       
    private var selectedRadioButton:RadioButton;
    private function initSelect(): void {
            selectedRadioButton = rb1;
    <mx:RadioButtonGroup id="rbg" selection="{selectedRadioButton}"
                       change="rbg_change(event);" />
                    <mx:HBox>
                  <mx:RadioButton id="rb1"
                          label="Active" group="{rbg}" />
                  <mx:RadioButton id="rb2"
                          label="Lock" group="{rbg}" />
    </mx:HBox>
    Thanks

    it's simple set its selected property true. For instance
    myRadioButtonSelectedOnStart.selected="true"
    Sincerely,
    Michael
    El 14/05/2009, a las 10:32, "master.card" <[email protected]> escribió:
    >
    Hi,
    >
    There are tons of examples on the websites to show you how to detect 
    selected radioButton or click event. But It is not easy to find aone 
    example to show you how to set selected radioButton.
    >
    Here is my code, but not working, Is it not well handle on it for 
    Flex?
    >
    private var selectedRadioButton:RadioButton;
    private function initSelect(): void {
            selectedRadioButton = rb1;
    <mx:RadioButtonGroup id="rbg" selection=""
                       change="rbg_change(event);" />
                    <mx:HBox>
                  <mx:RadioButton id="rb1"
                          label="Active" group="" />
    >               <mx:RadioButton id="rb2"
    >                       label="Lock" group="" />
    </mx:HBox>
    >
    >
    >
    Thanks
    >

  • How do I select texte discontinuouly : one word here and another there

    How do I select texte discontinuouly : one word here and another there, etc.

    Use Pages '09.
    Feature has been removed from Pages 5, along with 100+ others.
    Peter

  • JTextPane - setting selected text colour

    Ok, I have a bit of a problem. Here is some general information about my program.
    I have a JTextPane called "DDITextArea" and I can type in it and stuff. I want to be able to select some of the text and use a JColorChooser to set the text to that color of my choice. I am doing a bit of experimentation with the swing components and messed around with a JColorChooser. Here is the code for the chooser.
        ColourOption.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (first) {
              first = false;
              chooser.setPreviewPanel(new CustomPane());
            JDialog dialog = JColorChooser.createDialog(RecipeBrowser.this, "Demo 3", true, chooser, new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                    c = chooser.getColor();
                }, null);
            dialog.setVisible(true);
    *I NEED SOMETHING HERE TO SET THE SELECTED TEXT TO THE COLOUR I CHOOSE WITH THE JCOLOURCHOOSER
    *I HAVE A JTEXTPANE AND I WANT TO BE ABLE TO SELECT SOME TEXT THEN USE THE JCOLORCHOOSER TO SET THE COLOUR OF THE SELECTED TEXT
        });as you can see from the comments near the end of the code sample, I need to know how to set the selected text to Color c. I don't know if there is a method for this. I looked at the online Java syntax database but to no luck. Just to ensure that there is no misunderstanding I will give an example:
    DDITextArea has the sentence "The dog is wet and smelly" and its default font colour is black. If I highlight the words "The Dog", open the ColorChooser and select red, the words "The Dog" will be red while everything else is black.
    If it is any help, here is where my DDITextArea is created
              final JTextPane DDITextArea = new JTextPane();
              JScrollPane DDITextAreaScrollPane = new JScrollPane(DDITextArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
              //DDITextArea.setLineWrap(true);
              //DDITextArea.setWrapStyleWord(true);
              DDITextArea.setEnabled(true);
              DDITextArea.setEditable(true);
              DDITextArea.setVisible(true);
              gbc.fill = GridBagConstraints.BOTH;
              gbc.anchor = GridBagConstraints.CENTER;
              gbc.gridx = 1;
              gbc.gridy = GridY;
              gbc.gridwidth = 1;
              gbc.gridheight = 1;
              gbc.weightx = 1;
              gbc.weighty = 1;
              gbl.setConstraints(DDITextAreaScrollPane, gbc);
              PrintTab.add(DDITextAreaScrollPane);Am I missing any necessary syntax to do this or is there something much more complicated involved?

    Sorry for the double post but I figured it out. I missed the answer. This is a clear sign I must stop doing past-midnight research.
    Anyways, for any folds that have trouble with this in the future, here you go. I hope someone, somewhere, sometime, will have need for this.
        ColourOption.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (first) {
              first = false;
              chooser.setPreviewPanel(new CustomPane());
            JDialog dialog = JColorChooser.createDialog(RecipeBrowser.this, "Demo 3", true, chooser, new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                    c = chooser.getColor();
                }, null);
            dialog.setVisible(true);
    //THE CODE BELOW THIS COMMENT IS WHAT I ADDED
    new StyledEditorKit.ForegroundAction("", c).actionPerformed(null);
    //THE CODE ABOVE THIS COMMENT IS WHAT I ADDED
        });

  • How to set the size of JTextPane according to the size of text??

    hello
    how can i set the size of JTextPane according to the size of text it would contain in such a way that JTextPane should not have ScrollBar.

    StanislavL wrote:
    width should be defined for your container width. suppose you have a very long row of text. Widht full screen widht it wraps into 2 lines but if you set widht of your window to half screen widht there should be 4 lines.
    But you can use the same code and get preferred widht as well.u mean like this :
    objTextPane.getParent().getWidth();Edited by: 811243 on Sep 6, 2011 5:32 AM

  • How to make selected text in a JTextPane HyperLink

    Hi guys,
    I am trying to Hyperlink the displayed text in JTextPane but its not occuring.Does anybody has some suggestion.I am posting the part of my code which i was using to hyperlink the given text but its not working....Plz give some suggestions regarding this....
    public void addHyperLink()
    Document doc;
    URL url=null;
    try {
    url = new URL("http://www.gmail.com");
    } catch (MalformedURLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    SimpleAttributeSet attributeSet= new SimpleAttributeSet();
    attributeSet.addAttribute(HTML.Attribute.HREF, url.toString());
    SimpleAttributeSet attributeSet1= new SimpleAttributeSet();
    attributeSet1.addAttribute(HTML.Tag.A,attributeSet);
    String text=pane.getText(); // pane is instance of JTextPane
    try {
    doc=pane.getDocument();
    doc.insertString(0,text,attributeSet1);
    } catch (BadLocationException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    }

    Search the forum this question is asked a lot. Also if you post code please post a Short,Self Contained, Compilable and Executable, Example Program and use code format tags.

  • How to set selected file in FileChooser showSaveDialog to default file name

    Hi,
    How do I set selected file in JavaFX 2.0 FileChooser showSaveDialog, so I can prompt the user with a suggested default file name?
    I am converting a Java Swing application I wrote a few years ago to JavaFX 2.0.
    In the Swing application, I use setSelectedFile() as follows:
    JFileChooser jFileChooser = new JFileChooser();
    jFileChooser.setSelectedFile(new File(backupfile));
    jFileChooser.setCurrentDirectory(new File(outputDirectory));
    FileFilter filter = new FileNameExtensionFilter("Comma Delimited (*.csv)", "csv");
    jFileChooser.addChoosableFileFilter(filter);
    jFileChooser.setFileFilter(filter);
    filter = new FileNameExtensionFilter("XML Document (*.xml)", "xml");
    jFileChooser.addChoosableFileFilter(filter);
    jFileChooser.setAcceptAllFileFilterUsed(false);
    jFileChooser.setDialogTitle("Export File");
    int returnVal = jFileChooser.showDialog(jFrame, "Export");
    This would show a file chooser with the file name text field pre-populated with a default backup file name.
    I can't find an equivalent in JavaFX.
    Also, in the Swing application, I was able to determine which extension filter was selected at run time using getFileFilter().getDescription() as follows:
    String extension = jFileChooser.getFileFilter().getDescription();
    if (extension.equals("XML Document (*.xml)")) { ...
    I can't find an equivalent in JavaFX.
    Thanks,
    Barry

    You can use the open sequence file method on the application manager (then you only need to wire the file path)
    Rodéric L
    Certified LabVIEW Architect

  • How to catch selected text in JTable Column

    Hi there,
    I am learning JTable. Need help for How to get the selected text from the JTable Column which is set to be editable.
    for example in JTextFiled you have method on getSelectedText(), is there any method for tracking the selected text.
    Thanks in advance
    Minal

    Here's an example of the model I used in my JTable. Not the "getValueAt" method & "getRecordAt" method. You will have to have a Record object - but it only contains the attributes of an inserted record (with appropriate getters & setters). Hope this helps.
    public class FileModel5 extends AbstractTableModel
    public boolean isEditable = false;
    protected static int NUM_COLUMNS = 3;
    // initialize number of rows to start out with ...
    protected static int START_NUM_ROWS = 0;
    protected int nextEmptyRow = 0;
    protected int numRows = 0;
    static final public String file = "File";
    static final public String mailName = "Mail Id";
    static final public String postName = "Post Office Id";
    static final public String columnNames[] = {"File", "Mail Id", "Post Office Id"};
    // List of data
    protected Vector data = null;
    public FileModel5()
    data = new Vector();
    public boolean isCellEditable(int rowIndex, int columnIndex)
    // The 2nd & 3rd column or Value field is editable
    if(isEditable)
    if(columnIndex > 0)
    return true;
    return false;
    * JTable uses this method to determine the default renderer/
    * editor for each cell. If we didn't implement this method,
    * then the last column would contain text ("true"/"false"),
    * rather than a check box.
    public Class getColumnClass(int c)
    return getValueAt(0, c).getClass();
    * Retrieves number of columns
    public synchronized int getColumnCount()
    return NUM_COLUMNS;
    * Get a column name
    public String getColumnName(int col)
    return columnNames[col];
    * Retrieves number of records
    public synchronized int getRowCount()
    if (numRows < START_NUM_ROWS)
    return START_NUM_ROWS;
    else
    return numRows;
    * Returns cell information of a record at location row,column
    public synchronized Object getValueAt(int row, int column)
    try
    FileRecord5 p = (FileRecord5)data.elementAt(row);
    switch (column)
    case 0:
    return (String)p.file;
    case 1:
    return (String)p.mailName;
    case 2:
    return (String)p.postName;
    catch (Exception e)
    return "";
    public void setValueAt(Object aValue, int row, int column)
    FileRecord5 arow = (FileRecord5)data.elementAt(row);
    arow.setElementAt((String)aValue, column);
    fireTableCellUpdated(row, column);
    * Returns information of an entire record at location row
    public synchronized FileRecord5 getRecordAt(int row) throws Exception
    try
    return (FileRecord5)data.elementAt(row);
    catch (Exception e)
    throw new Exception("Record not found");
    * Used to add or update a record
    * @param tableRecord
    public synchronized void updateRecord(FileRecord5 tableRecord)
    String file = tableRecord.file;
    FileRecord5 p = null;
    int index = -1;
    boolean found = false;
    boolean addedRow = false;
    int i = 0;
    while (!found && (i < nextEmptyRow))
    p = (FileRecord5)data.elementAt(i);
    if (p.file.equals(file))
    found = true;
    index = i;
    } else
    i++;
    if (found)
    { //update
    data.setElementAt(tableRecord, index);
    else
    if (numRows <= nextEmptyRow)
    //add a row
    numRows++;
    addedRow = true;
    index = nextEmptyRow;
    data.addElement(tableRecord);
    //Notify listeners that the data changed.
    if (addedRow)
    nextEmptyRow++;
    fireTableRowsInserted(index, index);
    else
    fireTableRowsUpdated(index, index);
    * Used to delete a record
    public synchronized void deleteRecord(String file)
    FileRecord5 p = null;
    int index = -1;
    boolean found = false;
    int i = 0;
    while (!found && (i < nextEmptyRow))
    p = (FileRecord5)data.elementAt(i);
    if (p.file.equals(file))
    found = true;
    index = i;
    } else
    i++;
    if (found)
    data.removeElementAt(i);
    nextEmptyRow--;
    numRows--;
    fireTableRowsDeleted(START_NUM_ROWS, numRows);
    * Clears all records
    public synchronized void clear()
    int oldNumRows = numRows;
    numRows = START_NUM_ROWS;
    data.removeAllElements();
    nextEmptyRow = 0;
    if (oldNumRows > START_NUM_ROWS)
    fireTableRowsDeleted(START_NUM_ROWS, oldNumRows - 1);
    fireTableRowsUpdated(0, START_NUM_ROWS - 1);
    * Loads the values into the combo box within the table for mail id
    public void setUpMailColumn(JTable mapTable, ArrayList mailList)
    TableColumn col = mapTable.getColumnModel().getColumn(1);
    javax.swing.JComboBox comboMail = new javax.swing.JComboBox();
    int s = mailList.size();
    for(int i=0; i<s; i++)
    comboMail.addItem(mailList.get(i));
    col.setCellEditor(new DefaultCellEditor(comboMail));
    //Set up tool tips.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for mail Id list");
    col.setCellRenderer(renderer);
    //Set up tool tip for the mailName column header.
    TableCellRenderer headerRenderer = col.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the Mail Id to see a list of choices");
    * Loads the values into the combo box within the table for post office id
    public void setUpPostColumn(JTable mapTable, ArrayList postList)
    TableColumn col = mapTable.getColumnModel().getColumn(2);
    javax.swing.JComboBox combo = new javax.swing.JComboBox();
    int s = postList.size();
    for(int i=0; i<s; i++)
    combo.addItem(postList.get(i));
    col.setCellEditor(new DefaultCellEditor(combo));
    //Set up tool tips.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for post office Id list");
    col.setCellRenderer(renderer);
    //Set up tool tip for the mailName column header.
    TableCellRenderer headerRenderer = col.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the Post Office Id to see a list of choices");
    }

  • How to set selection screen

    I have a question that ...
    i have 2 options --
    when select 1st option , show group1 screen
    when select 2nd option, show group2 screen
    like the follow ..which is pretty work!....but i have another question that how to set the screen field ..
    my question is that if i select group1 screen...i want to set
    if S1_EBELN = '' and S1_IHREZ = ''.
        message e398 with 'pls input one of these two options!'.
      elseif S1_EBELN ne '' and S1_IHREZ ne ''.
        message e398 with 'Only one of these two options input is allowed&#65281;'.
      endif.
    i've tried to insert these statement within the LOOP...but not work ......
    so can anyone know how to set?
    PARAMETERS:
    R1 RADIOBUTTON GROUP OPT1 USER-COMMAND R DEFAULT 'X'.
    PARAMETERS:
    R2 RADIOBUTTON GROUP OPT1.
    SELECTION-SCREEN BEGIN OF BLOCK RPT1 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS: S1_BUKRS FOR EKKO-BUKRS MODIF ID ABC. 
    SELECT-OPTIONS: S1_EBELN FOR EKKO-EBELN MODIF ID ABC . 
    SELECT-OPTIONS: S1_IHREZ FOR EKKO-IHREZ MODIF ID ABC .  
    SELECTION-SCREEN END OF BLOCK RPT1.
    SELECTION-SCREEN BEGIN OF BLOCK RPT2 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS:  S2_BUKRS FOR EKKO-BUKRS MODIF ID DEF.
    SELECT-OPTIONS: S2_MBLNR FOR MKPF-MBLNR MODIF ID DEF.   
    SELECT-OPTIONS: S2_XBLNR FOR MKPF-XBLNR MODIF ID DEF .   
    SELECTION-SCREEN END OF BLOCK RPT2.
    IF R1 = 'X'.
        LOOP AT SCREEN.
          IF screen-group1 = 'DEF'.
            screen-input = '1'.
            SCREEN-required = '1'.
            SCREEN-INVISIBLE = '1'.
            screen-input = '0'.
            screen-output = '1'.
            screen-active = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
    ELSEIF R2 = 'X'.
        LOOP AT SCREEN.
          IF screen-group1 = 'ABC' .
            screen-active = '0'.
            screen-input = '0'.
            screen-output = '1'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.

    Modified ur code .
    tables : ekko, mkpf.
    PARAMETERS : R1 RADIOBUTTON GROUP RG USER-COMMAND R DEFAULT 'X'.
    PARAMETERS : R2 RADIOBUTTON GROUP RG .
    SELECTION-SCREEN BEGIN OF BLOCK RPT1 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS: S1_BUKRS FOR EKKO-BUKRS MODIF ID ABC.
    SELECT-OPTIONS: S1_EBELN FOR EKKO-EBELN MODIF ID ABC .
    SELECT-OPTIONS: S1_IHREZ FOR EKKO-IHREZ MODIF ID ABC .
    SELECTION-SCREEN END OF BLOCK RPT1.
    SELECTION-SCREEN BEGIN OF BLOCK RPT2 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS: S2_BUKRS FOR EKKO-BUKRS MODIF ID DEF.
    SELECT-OPTIONS: S2_MBLNR FOR MKPF-MBLNR MODIF ID DEF.
    SELECT-OPTIONS: S2_XBLNR FOR MKPF-XBLNR MODIF ID DEF .
    SELECTION-SCREEN END OF BLOCK RPT2.
    at selection-screen output.
    IF R1 = 'X'.
    LOOP AT SCREEN.
    IF screen-group1 = 'DEF' .
    screen-active = '0'.
    MODIFY SCREEN.
    ENDIF.
    ENDLOOP.
    ENDIF.
    IF R2 = 'X'.
    LOOP AT SCREEN.
    IF screen-group1 = 'ABC' .
    screen-active = '0'.
    MODIFY SCREEN.
    ENDIF.
    ENDLOOP.
    ENDIF.
    at selection-screen .
    if r1 = 'X'.
    if s1_ebeln[] is initial and s1_ihrez[] is initial..
    message e001(zxx) with 'pls input one of these two options!'.
    endif.
    if NOT s1_ebeln[] IS initial.
    IF NOT s1_ihrez[] IS INITIAL.
    message e001(zxx) with 'only one entry in Ebeln or Ihrez is
    allowed'.
    ENDIF.
    ENDIF.
    endif.
    START-OF-SELECTION.
    WRITE:/ 'hi'.
    ***add on
    split the text into two texts .
    <b>if NOT s1_ebeln[] IS initial.
    IF NOT s1_ihrez[] IS INITIAL.
    message e001(zxx) with text-001 text-002.
    *'only one entry in Ebeln   = text-001
    or Ihrez is allowed'.       = text-002.</b> 
    regards,
    vijay

  • Set selected text as variable (CS3 with JS)

    How can I set a piece of selected text as a string variable?
    I'm running InDesign with InCopy CS3 on a Windows XP computer.

    If you mean "assign the selected text to a variable", then you could do this:
    var myText = app.selection[0].contents;
    Peter

  • How to wrap the text in JTextPane

    hi all,
    I have a problem with JTextPane. I have a JPanel which have 4 JButtons, one Details button and one JTextPane. I have set JTextPane to JScrollPane. Thing is when i press the Details button the JTextPane must be visible. Window size is changing. can any one say how to wrap the text in the JTextPane.

    By default text in a JTextPane will wrap, so I don't understand the question.
    Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/text.html]Using Text Components for a working example.

  • ComboBox Problem to change the size of selected text in JTextPane.

    hi 2 all!
    I have a problem in combo box actions, when i change the item in the combo its set is not set at that time but that action is performed when next action is taken, i have used combobox.setAction(new StyledEditorKit.FontSizeAction(" click", 12);) command to set the size of the selected text
    Plz suggest the solution also if possible,plz provide some code for this
    Action action1 = new StyledEditorKit.FontSizeAction(
                                                 "double click", 12);
                                       Action action2 = new StyledEditorKit.FontSizeAction(
                                                 "double click", 14);
                                       Action action3 = new StyledEditorKit.FontSizeAction(
                                                 "double click", 18);
    s2 = (String) cb7.getSelectedItem();
                                       if (s2.equals("Small")) {
                                            cb7.setAction(action1);
                                            e1.setSource(cb7);
                                                      } else
                                       if (s2.equals("Medium")) {
                                            cb7.setAction(action2);
                                            e1.setSource(cb7);
                                                                          } else if (s2.equals("Large")) {
                                            cb7.setAction(action3);
                                            // e1.setSource(cb7);
    when i chooze any combobox item then according to that item i set the Action on ComboBox but that action is not working properly on the selected text in the JTextPane..means selected text in JText Pane is not changes its Size according to the comboBox selected ITEM.
    PLZ plzzzzzzzzzz help me:((.i will be thankfull to u.
    thanx in advance..

    this code is not working properly according to the action i set on comboBox.Thats correct, the setAction() method is used to invoke an existing Action on the combo box, not create a new Action.
    What you need to do is have a single action that uses the information from the item that was selected to build a dynamic Action to change the font. Something like:
    public void actionPerformed(ActionEvent e)
         JComboBox comboBox = (JComboBox)e.getSource();
         int fontSize = Integer.parseInt( comboBox.getSelectedItem().toString() );
         Action fontAction = new StyledEditorKit.FontSizeAction("size", fontSize);
         fontAction.actionPerformed(null);
    }

Maybe you are looking for