How to draw tab key char into Graphics g as space?

Hi, all.
following pg.drawString(token, 0, y); keep draw "\t" strange character like "o".
eg: "\tpublic static"--after draw..--> opublic static".
As you see below, I replace "\t" with " "(blankes).
I test replaceString method. it works fine.
but, once it draw it, it keep draw "o" string where the "\t" was.
What's problem?
//called for print.
public int print(Graphics pg, PageFormat pageFormat,
          int pageIndex) throws PrinterException {
//some code...
String tabReplace=" ";
StringTokenizer parser = new StringTokenizer(contents, "\n");
     try {
     while(parser.hasMoreTokens()) {
          String token=replaceString(parser.nextToken(), "\t", tabReplace);
          pg.drawString(token, 0, y);
          y+=fm.getHeight();
          y+=lineSpace;//lineSpace comes from use option               
     } catch (NoSuchElementException e) {
     System.out.println(e);
//some code..
     public String replaceString(String contents, String replace,
                                             String with){
          int indexHead=0, indexTail=0;
          while(( indexTail = contents.indexOf(replace, indexHead) ) >0){
               contents=contents.substring(indexHead, indexTail)+
                         with+contents.substring(indexTail+replace.length());
               indexHead+=with.length();
          return contents;
f

Any unprintable character draws the square 'o' on a graphics object, not only \t. Since your code is correct, it will replace away all \t in the string, means there are no \t left in the string. Since there is still unprintable character resident in the string, you need to check that the string that you draw is the correct one or which character that is unprintable. How about looping through the string and print the char-as-int to system int. Look for fairly low numbers < 32 and 127 as they would not be printable by normal means.
Regards,
Peter Norell

Similar Messages

  • How to supress tab key stopping at lables

    Hi everyone,
    after upgrading to 5.0 from 4.02 and changing the theme to 26 (productivity), there is now a problem with the tab key.
    Before, the tab key moved the entry scope simply to the next dialog field or list value; now the tab stops also at the labels.
    That means, to skip from one entry field to the next, you have to press tab twice.
    How can I change this back to the old way ?

    Norbert W. wrote:
    thank you for your response. I came from theme no.2 (Builder blue). I´ve tested this case with Firefox and Chrome (actual versions). The label templates are mostly "Optional with help", "Optional" and "Required with help".
    Now I found that "optional" is working as expected (without tabstop), while the others are producing stops.
    This is happening because the "with help" label templates contain links for displaying item-level help, and they therefore receive focus when using keyboard navigation. This is actually good accessibility practice, and you are recommended to retain it. Changing labels so they don't use "with help" templates where there is no help is also appropriate.
    The workaround used to avoid this standard behaviour in theme 2 is to include a tabindex attribute with a sequence number higher than the possible number of page items on the help links:
    <label for="#CURRENT_ITEM_NAME#" id="#LABEL_ID#" tabindex="999"><a class="optional-w-help" href="javascript:apex.theme.popupFieldHelp('#CURRENT_ITEM_ID#','&SESSION.')" tabindex="999">
    You could revert to this behaviour by editing the theme 26 "with help" label templates to include the tabindex:
    <label for="#CURRENT_ITEM_NAME#" id="#LABEL_ID#" class="uOptional"><a class="uHelpLink" href="javascript:apex.theme.popupFieldHelp('#CURRENT_ITEM_ID#','&SESSION.')" tabindex="999">

  • How to use tab key with JTextArea to shift focus

    Hi
    My problem is simple as whenevr i use tab key in my JTextArea, instaed of shifting focus to next component, it adds a tab space to my text.
    How do i shift focus out of my JTextArea.
    Ashish

    you can also redefine the textarea's TAB Key behaviour. The tutorial has a good example for that - better than i would be able to describe :-)
    look at http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html

  • How to recognize "tab" key?

    hi all,
    i wrote an editor using swings. To provide input through console, i used the event handlers for keyboard events like
    keypressed(), key released()etc.. i also provided some tool bar for opening a file, saving etc. i was able to define the action for almost all the keys on the keyboard, except for some keys. i was unable to get the control of tab key. when i am pressing a tab key, the control is movig on toll bar options only. the conrol is not getting int the frame, on which i used to display the text.
    what i finally require is that how can i get the control of 'tab key' and how can i define some actions that are to be performed on pressing tab keys.
    i will be thankful if any body can help me in this regard.
    bye one and all,

    Try overiding the method isManagingFocus:
    public boolean isManagingFocus() {
    return true; //in order to catch TAB key
    in your text area.
    Netta

  • How to use TAB key  rolling on the rank of a JTabbedPane ?

    I hope I can use TAB key to switch the different option item , how to do this ?
    Liwei

    You need to use a key listener. Something like:
            static class myKeyListener implements KeyListener
                    //KeyListener reuired methods
                    public void keyPressed(KeyEvent e)
                            int a = e.getKeyCode();
                            //Check if they pressed tab
                            if (a == e.VK_TAB)
                                   //Do whatever
                    public void keyReleased(KeyEvent e)
                    public void keyTyped(KeyEvent e)
            }Then, put "myTabbedPane.add(myInstanceOfMyKeyListener" up where you're creating the pane, replacing "myTabbedPane" and "myInstanceOfMyKeyListener" with whatever variables you're using.

  • How to load tab limited data into apllication server

    Hello All,
    I have 2 questions.
    1)I have data in a table,i want to place this data in the applcation server with tabdelimiter in ASC.How do i proceed?
    2)I have the data in my application server in a compressed text format,i want to download this data into a zip file (i am using the filetype 'BIN' to download this data to presentation server.However when i unzip this file my file is not tabdelimited.Is there any way i can download the file of type Bin into a zip file so that when i unzip it ,it should be tabdelimited?
    Thanks in advance.
    Sujatha gokaraju

    Hello,
    Do like this
    PARAMETERS: P_FILE TYPE RLGRAP-FILENAME,
                P_TRZEI      TYPE C DEFAULT ';'.
    PERFORM DOWNLOAD_DATA.
    *&      Form  DOWNLOAD_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DOWNLOAD_DATA.
      DATA: OUTPUT TYPE STRING,
            L_F_NETWR(21) TYPE C,
            L_F_ERDAT_OR(10),
            L_F_ERDAT_IN(10),
            L_F_ERDAT_DE(10),
            L_F_POSID LIKE PRPS-POSID.
      OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.
      IF SY-SUBRC = 0.
        LOOP AT G_T_OUTTAB.
          CLEAR L_F_NETWR.
          WRITE: G_T_OUTTAB-NETWR TO L_F_NETWR,
                 G_T_OUTTAB-ERDAT_OR TO L_F_ERDAT_OR,
                 G_T_OUTTAB-ERDAT_IN TO L_F_ERDAT_IN,
                 G_T_OUTTAB-ERDAT_DE TO L_F_ERDAT_DE.
          CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
               EXPORTING
                    INPUT  = G_T_OUTTAB-PS_PSP_PNR
               IMPORTING
                    OUTPUT = L_F_POSID.
          IF NOT P_TAB IS INITIAL.
            CONCATENATE G_T_OUTTAB-VBELN
                        G_T_OUTTAB-POSNR
                        G_T_OUTTAB-VKBUR
                        L_F_POSID
                        G_T_OUTTAB-BSTKD
                        L_F_NETWR
                        L_F_ERDAT_OR
                        L_F_ERDAT_IN
                        G_T_OUTTAB-VBELN_IN
                        L_F_ERDAT_DE
                        G_T_OUTTAB-VBELN_DE
                        INTO OUTPUT
                        SEPARATED BY CON_TAB.
          ELSE.
            CONCATENATE G_T_OUTTAB-VBELN
                        G_T_OUTTAB-POSNR
                        G_T_OUTTAB-VKBUR
                        L_F_POSID
                        G_T_OUTTAB-BSTKD
                        L_F_NETWR
                        L_F_ERDAT_OR
                        L_F_ERDAT_IN
                        G_T_OUTTAB-VBELN_IN
                        L_F_ERDAT_DE
                        G_T_OUTTAB-VBELN_DE
                        INTO OUTPUT
                        SEPARATED BY P_TRZEI.
          ENDIF.
          TRANSFER OUTPUT TO P_FILE.
          CLEAR L_F_NETWR.
        ENDLOOP.
      ELSE.
        MESSAGE E041(S9) WITH P_FILE.
      ENDIF.
      CLOSE DATASET P_FILE.
    ENDFORM.                    " DOWNLOAD_DATA
    Cheers,
    Vasanth

  • How to paste tabbed data directly into FM7 table cells?

    <<<<on edit.... changed FM8 to FM7... I have FM7, not FM8>>>
    Hello
    I'm working on a documentation job that requires a pasting external data into existing table cells in FM7.
    I have tried several things but I can't find a way to paste the data directly into the table cells.  The source data can be delimited text, or spreadsheet cells. Neither can be pasted into an existing table.   The only way I can make this work is to first paste it into FM as text, then convert it to another table, and then copy/paste from that table into the existing one.  This is a lot of extra work and it seems there should be a way to paste external data directly across table cells.   I also tried "paste special" but that is not an option when I have table cells selected.
    Any ideas???
    It would be much appreciated!
    Thanks
    Gary Beckwith

    Gary, just had a thought -- I've worked on several projects where I used variables in tables that might work better for you.
    Basically the idea is to pre-populate the tables in your chapter with variables in the cells, and then import a minimalist MIF file that only contains the variable definitions for the pre-existing variables.  The minimalist MIF file can be made quite easily from a database or from an Excel CSV or TSV export by using various scripting utilities to convert comma-delimited text into the MIF syntax.
    I've created chapters that had hundreds of thousands of cells with variables in them, and updating the variables is incredibly quick.
    The best way to approach the variable naming is to come up with a convention that is easy to apply, I found .r1c1 etc to be a good starting point (the period so that the variables all sort in the same place in FM, the lower-case letters to make the variable's name as horizontally short as possible.

  • How to keep pages from running into each other's space?

    OK, my aim is to plow through this and get this one book done and worry about controlling the unsightly TOC thumbnails in other versions when I learn Pages.
    My problem now is that I am doing this picture book and the registry of the pages gets out of whack with one picture partially going into another page. In Preview it shows up even moreso than in IBA. Is there a way to get them to snap and stay in place? I am inserting a widget gallery and a full page photo on each page. If one goes out and I correct it, it seems the others get slightly off as well. Can you lock placement of each page to prevent this? Thanks.

    Any time I read 'lock placement' (w/these kinds of tools), I think styles.
    And while the design/structure of the style itself is 'locked', applying it may be a manual effot, unless of course you're working strictly with a template, etc.

  • ItemFocusOut not catching  "TAB" key in Datagrid edited cell?

    In DataGrid, "keyUp" can catch "TAB" key when it is pressed,
    but the Keyboard event has less information needed. I tried
    itemFocusOut, but it seems DataGridEvent would not catch it. Any
    tips on how to make "TAB" key generate DataGridEvent or similar
    event?
    Platforms with this issue: WIN-XP/JDK-1.6/Air-1.5/FLEX
    SDK-3.2
    Thanks!
    -Herbert

    Let me rephrase like this:
    In our application, a DataGrid’s edited cell has
    “itemEditEnd” and “itemEditBeginning”
    handlers defined. However when a “TAB” key is pressed
    to navigate from one editable cell to another editable cell, none
    of the above handlers can catch this special key stroke event.
    Our intention is to make “TAB” key to emit an
    event that can be caught by above handlers. Or, in other words, we
    would like make “TAB” key to be similar(in the sense of
    generating events) to that of “Enter” key when pressed.

  • ObjectId@: How to drawn the ObjectId@ token into the Crystal Report????

    In all documentation about the tokens to be used in order to have the right document published in CR, there's no reference how SBO draw the the ObjectId@ into the report. In the standard CR reports SAP delivers with SBO, the DocKey@ is drawn by a formule (table.DocEntry = {?DocKey}.
    I can't find anything in the standard CR reports, how this is done with the Token ObjectId@.
    Does anyone have specific information about this?
    With regards,
    Freek

    Hello Gordon,
    I don't agree to that. If you look in the orignal documen '' How to Work with Crystal Reports in
    SAP Business One " you can read:
    The ObjectId@ token is recommended for inclusion in Crystal Reports layouts that you want
    to assign to multiple sales and purchasing documents. For example, you can include the
    ObjectId@ token if you want to include dynamic titles that change according to different
    document types.
    Furtheron, if you look in the standard CR reports for marketing lay-outs, the ObjectId@ token is populated and filled with a condition. But I can't find where in de Crystal Report. Not in the filter condition like the DocKey@ token.
    grz,
    Freek

  • Override "crtl + tab" key behaviour with "tab" key for JtextArea .

    I am trying to override the "crtl + tab" key behaviour for JTextArea with "tab" key plus add my own action. I am doing the following.
    1. Setting Tab as forward traversal key for the JTextArea (the default traversal key from JTexArea is "crtl + Tab").
    2. Supplementing the "crtl + Tab" key behaviour with my custom behaviour.
    For the point 2 above, I need to get hold of the Action represented by the "crtl + Tab" key so that I could use that and then follow with my own custom action. But the problem is that there is no InputMap entry for "crtl + tab". I dont know how the "crtl + tab" key Action is mapped for JTextArea. I used the following code to search the InputMap.
                System.out.println("Searching Input Map");
                for (int i = 0; i < 3; i++) {
                    InputMap iMap = comp.getInputMap(i);
                    if (iMap != null) {
                        KeyStroke [] ks = iMap.allKeys();
                        if (ks  != null) {
                            for (int j = 0;j < ks.length ;j++) {
                                System.out.println("Key Stroke: " + ks[j]);
                System.out.println("Searching Parent Input Map");
                for (int i = 0; i < 3; i++) {
                    InputMap iMap = comp.getInputMap(i).getParent();
                    if (iMap != null) {
                        KeyStroke [] ks = iMap.allKeys();
                        if (ks  != null) {
                            for (int j = 0;j < ks.length ;j++) {
                                System.out.println("Key Stroke: " + ks[j]);
                }In short, I need to get the Action associated with the "crtl + tab" for JTextArea.
    regards,
    nirvan.

    There is no Action for Ctrl+TAB. Its a focus traversal key.

  • Char into String

    How do i convert a char into a string?
    Thanks

    char c = 'f';
    Character character = new Character(c);
    String charAsString = character.toString();
    or better
    String charAsString = String.valueOf(c);
    Alan

  • How to recognize the tab key in a JTextField

    I have a drawing program with a main window and a tools palette, which is a JDialog. The tools palette has JToggleButtons and one JTextField. When you have the focus in the JTextField and you press tab repeatedly, it tabs through all the JToggleButtons and then back into the JTextField.
    However I would like to recognize the pressing of the tab key and ask for the focus to go back to the main window.
    I subclassed the JTextField, added a KeyAdapter, but it does not recognize the tab key. I also added the processKeyBinding method, but it doesn't recognize the tab key either.
    How can I recognize the tab key?
    Here is a self-contained test program that illustrates the problem:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class AnanyaCurves extends JFrame
      Tools tools;
      public AnanyaCurves(Dimension windowSize)
        Basics.ananyaCurves = this;
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        setTitle("Ananya Curves");
        tools = new Tools(this);
      public static void main(String[] args)
        int toolsWidth;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        toolsWidth = 200;
        Dimension windowSize = new Dimension(screenSize.width - toolsWidth, screenSize.height - 58);
        AnanyaCurves ananyaCurves = new AnanyaCurves(windowSize);
        ananyaCurves.pack();
        ananyaCurves.setBounds(toolsWidth, 0, windowSize.width, windowSize.height);
        ananyaCurves.setVisible(true);
        ananyaCurves.requestFocus();
      public void setVisible(boolean b)
        tools.setVisible(b);
        super.setVisible(b);
    class Basics extends java.lang.Object
      public static AnanyaCurves ananyaCurves;
      public Basics()
    class Tools extends JDialog
      JToggleButton btnGrid;
      JTextField textGrid;
      JPanel panel;
      public Tools(JFrame frame)
        super(frame, "Tools", false);
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        btnGrid = makeBtn("Grid");
        textGrid = makeTextField();
        panel = makePanel();
        pack();
      public JToggleButton makeBtn(String name)
        JToggleButton btn = new JToggleButton();
        btn.setMaximumSize(new Dimension(108, 24));
        btn.setPreferredSize(new Dimension(108, 24));
        btn.setText(name);
        btn.setFont(new Font("Verdana", Font.PLAIN, 11));
        btn.setMargin(new Insets(5, 10, 5, 10));
        btn.setOpaque(true);
        return btn;
      public ACJTextField makeTextField()
        ACJTextField textField = new ACJTextField();
        textField.setFont(new Font("Verdana", Font.PLAIN, 12));
        textField.setMaximumSize(new Dimension(108, 20));
        textField.setPreferredSize(new Dimension(108, 20));
        textField.setText("0.25");
        textField.setEnabled(true);
        return textField;
      public JPanel makePanel()
        JPanel panel = new JPanel();
        panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        panel.add(btnGrid);
        panel.add(textGrid);
        getContentPane().add(panel);
        return panel;
    class ACJTextField extends JTextField
      KeyAdaption keyAdaption;
      public ACJTextField()
        super();
        keyAdaption = new KeyAdaption();
        this.addKeyListener(keyAdaption);
      class KeyAdaption extends KeyAdapter
        public void keyPressed(KeyEvent event)
          int keyCode = event.getKeyCode();
          if (keyCode == KeyEvent.VK_TAB)
            Basics.ananyaCurves.requestFocus();
      protected boolean processKeyBinding(KeyStroke keyStroke, KeyEvent keyEvent, int int2, boolean boolean3)
        int keyCode = keyEvent.getKeyCode();
        if (keyCode == KeyEvent.VK_TAB)
          Basics.ananyaCurves.requestFocus();
          return false;
        return super.processKeyBinding(keyStroke, keyEvent, int2, boolean3);
    }Thanks for looking at this.

    Wow, Michael, you work like magic! Thanks so much! I would be happy to give you a commercial key to my Ananya Curves program also once the second release is on my website. It's a program for drawing curves in an easier way without pulling on tangent lines, with all control points right on the curve. Just send me an email to [email protected] if you are interested!

  • When i draw a line it coverted into graphic by default

    hi,
    when i draw a line it coverted into graphic automatically, i
    have own to break apart it with ctrl+b.
    pls help me. this was not before .

    fooflash wrote:
    > hi,
    > when i draw a line it coverted into graphic
    automatically, i have own to break apart it with ctrl+b.
    > pls help me. this was not before .
    select drawing tool, any tool, hit the J key.
    Hitting J will alternately change your drawing from raw shape
    to group shape.
    It's the little icon next to the MAGNET under the 'options'
    on tool bar
    Best Regards
    Urami
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • How do I use a Tab key to maximize a frame?

    How can I use a Tab key (vk_tab) pressed on the focused frame to actually maximize the frame... what action should it have attached to it?
    thanks!

    tab is the focus traversal key, so will be consumed before getting to your listener
    try this instead
        KeyboardFocusManager.getCurrentKeyboardFocusManager()
         .addKeyEventDispatcher(new KeyEventDispatcher(){
            public boolean dispatchKeyEvent(KeyEvent e){
              if(e.getID() == KeyEvent.KEY_PRESSED)
                if(e.getKeyCode() == KeyEvent.VK_TAB ) f.setExtendedState(JFrame.MAXIMIZED_BOTH);
              return false;
        });

Maybe you are looking for