Extend VTextField to dynamically underline font

Rather than use the Hyperlink bean (because it's pretty slow to load), I have taken the concepts in the ModCursor demo and built a simple class that extends VTextField, providing for the traditional webpage look of a hyperlink: the hand cursor, rollover bolding, etc...
I have left the font coloring and underlining to the text item properties; set when the developer builds the form.
Problem with leaving the underlining in the text item properties is that if the item is part of a multi-record block and the records don't fill the space allocated for them (the block can show up to 10, but perhaps only 5 records are loaded), then the "empty" records have little tiny dots where the underline of the empty text fields are.
I thought it would be simple to just add the underline in the implementation class, but it's not proving to be so simple. I've tried adding a TextAttribute whenever the font is set, but that doesn't "take".
Here's my code, anyone have any ideas on how to add the underline in the PJC?
I ripped out all the comments to reduce the size; I can comment about any part of it as necessary.
import java.awt.Font;
import java.awt.font.*;
import java.text.*;
import java.util.*;
import oracle.forms.ui.VTextField;
import oracle.forms.properties.ID;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Cursor;
public class Hotlink
extends VTextField
private Cursor stdCursor;
private int stdStyle;
public Hotlink()
super();
try
jbInit();
catch (Exception e)
e.printStackTrace();
private void jbInit() throws Exception
stdCursor = this.getCursor();
this.addMouseListener(new MouseAdapter()
public void mouseEntered(MouseEvent me)
if(getTextLength() > 0)
stdStyle = getFont().getStyle();
setFont(getFont().deriveFont(Font.BOLD));
setCursor(new Cursor(Cursor.HAND_CURSOR));
public void mouseExited(MouseEvent me)
if(getTextLength() > 0)
setFont(getFont().deriveFont(stdStyle));
setCursor(stdCursor);
public void setFont(Font font)
if(this.getTextLength() > 0)
Map attrs = font.getAttributes();
attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
font = new Font(attrs);
super.setFont(font);
}

Alright, no replies, but I figured out one way to do it.
It's kinda cheesy, but it works alright.
I saw that the Hyperlink bean actually drew a line to underline the text, so that's what I did.
I overloaded the paint method, and only draw a line if there is text in the item.
Actually, I only apply the moseover effects if there's text, too.
Anyway, for those seeking the same answers as I was, here's my code, stripped of comments because of size considerations:
import java.awt.Graphics;
import java.awt.FontMetrics;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.FontMetrics;
import oracle.forms.ui.VTextField;
import oracle.forms.properties.ID;
import oracle.forms.handler.IHandler;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Cursor;
public class BoldLink
extends VTextField
private Cursor stdCursor;
private Font stdFont;
public BoldLink()
super();
public void init(IHandler h)
super.init(h);
stdCursor = this.getCursor();
this.addMouseListener(new MouseAdapter()
public void mouseEntered(MouseEvent me)
if(getTextLength() > 0)
setFont(stdFont.deriveFont(Font.BOLD));
setCursor(new Cursor(Cursor.HAND_CURSOR));
public void mouseExited(MouseEvent me)
if(getTextLength() > 0)
setFont(stdFont);
setCursor(stdCursor);
public void paint(Graphics g)
super.paint(g);
if (this.getTextLength() > 0)
FontMetrics metrics = getFontMetrics(getFont());
int strWidth = metrics.stringWidth(getText());
int yoffset = (int)(metrics.getHeight() * 0.95);
g.drawLine(0, yoffset, strWidth, yoffset);
public boolean setProperty(ID pid, Object value)
if(pid.getName().equals("FONT")) this.stdFont = (Font)value;
return super.setProperty(pid, value);
}

Similar Messages

  • Photoshop CS4 Extended, issues with resolution and font sizes on Mac

    I have Photoshop CS4 Extended, which worked fine on my old 15 inch Macbook Pro, I think it was 2011 and had high definition display.
    I now have a new 15 inch 'late 2013' Macbook Pro with retina display (2880 x 1800), and OS 10.9.4
    I have 2 problems:
    1) Using photoshop now, the resolution is a lot worse than with my old computer, even though my screen is higher resolution.
    For example, the images themselves are worse resolution on my display, far less crisp and more pixelated than any of my other programs. And even the windows such as 'save as...' screens are terribly pixelated also. Is there a way to fix this?
    2) When using the type tool, I cannot find how to change the size of the font. There used to be numbers which I could change, and also select the font type, both on the top menu bar always visible. Now there is not anymore. What there is there at the top, is what looks to be a bar on top of another bar. The top layer bar is on the left and reaches about one third of the way across the top, and I can drag it by its corner so it can extend more, but not less. It looks like there are things behind it which I cannot see, because it is over the top of them. Perhaps the text size and font options are stuck behind that. What can I do?
    Many thanks!
    Justin

    Hi JJMack, you said "Seems like you want a low resolution display hook and external display to it." I do not know what that means. I did a google search for "low resolution display hook" and it came up with zero results. Also I do not have an external display, only my laptop.
    Does anyone know what I can do to fix this issue? I would greatly appreciate any solution.
    Thank you!

  • 9 Pro Extended: How to get Typewriter Font & Font Size menus?

    I'm using Acrobat 9 Pro Extended on Windows/XP/SP3.
    I use the Typewriter Tool quite frequently to insert text into a document.
    I have the Typewrite Toolbar enabled and it is docked with my other toolbars.
    When I want to insert text I click the typewriter icon on the toolbar.
    My mouse pointer changes to a vertical bar with an A next to it.
    I move to the insertion point and left click which leaves a vertical bar positioned at the insertion point.
    Most of the time the Typewriter Toolbar is then 'opened' so that I can change the font or the font size.
    But sometimes when I click, those parts of the Typewriter Toolbar stay grayed out.
    The five icons between the typewriter icon and the drop down menus for font and font size are
    also grayed out. I've tried a number of things to try to make those items available but have
    never been able to figure out something that works. I can insert text. I just can't alter
    the characteristics of the text.
    Any ideas why the font and font size menus stay grayed out in the Typewriter Toolbar?
    Thanks!

    There is no way in PSE to change the font size of menu options in Photoshop Elements. You can try changing the resolution of your monitor.

  • What's the blue underlined font for links?

    I'm sure that ubiquitous blue, underlined, sans-serif font that everybody uses for a Web link must have some specs  ... i.e., 100% cyan with 15% K in arial or some such.
    Anybody set up a character style for it that looks realistic in print?
    Thanks,
    Eddie

    Eddie,
    In addition to what Herb said:
    When the creator of the site makes no changes to the default values of the website creation application, probably the font is fake Helvetica (also known as Arial) and the Link colour is 0000FF (all web colours are expressed as Hex triplets, corresponding to coded RGB values, 00 = 0, FF = 255); similarly the active link colour may be FF0000 and the visited link colour FF00FF.

  • Extending EventDispatcher with dynamic event types

    I'm currently trying to write my own class to extend the
    EventDispatcher class. My goal is to create a Service class which
    acts as a switchboard for incoming socket data. Incoming socket
    data is parsed to create an Event which is Dispatched to the
    appropriate Service object which dispatches the event to any
    registered listeners.
    The problem I'm having is that I'm confused about how to
    handle the event types -- the string parameter which is always
    supplied as the first argument to the addEventListener() function.
    In all the examples I've seen, the value supplied is a class
    constant like MouseEvent.CLICK or VideoEvent.READY. In the case of
    my application, I want the developer to define their own Event
    types without having to go and edit my class files. In other words,
    I'd like to use dynamic event types with my class--maybe something
    like the code I've attached.
    I'm not new to Actionscript but am very new to the
    EventDispatcher class. I'm wondering a bit what that first
    parameter really does in a strict programming sense -- i haven't
    seen it explained all that well in the piles of documentation I've
    read on the Adobe site so I don't really know if I need to define
    my own Event class or what and whether I have to define all those
    possible event type constants/strings in advance or what.
    Any help/advice would be much appreciated.

    I have looked it up here:
    Actionscript
    3.0 Language Reference
    and it just says that the first arg to 'addEventListener' is
    "The type of event" with no further explanation at all.
    I have read this:
    Flash
    Quick Starts: Programming With Actionscript 3.0: Event handling
    It doesn't help much either. It tells me I need the
    appropriate event object which makes me wonder DO I NEED MY OWN
    CLASS? For that first ard to addEventListener, it merely says
    "Substitute the appropriate constant". Given that I want to use
    dynamic types (i think so anyway) that is not helpful information
    either. Every single example on that page uses a class constant for
    event type.
    It links to
    this
    which says "First, the name of the specific event you want to
    respond to. Once again, each event is affiliated with a specific
    class, and that class will have a special value predefined for each
    event--sort of like the event's own unique name, which you should
    use for the first parameter." Still no useful detail about what
    that arg does and the insistence on constants.
    The quick start page also has a link title "Handling Events"
    in Programming ActionScript 3.0 but it links to some documentation
    titled "Working with XML". The only discussion of events in that 10
    or so pages is because some user posted a comment.
    I have read this
    entire
    article which is more helpful than anything in the flash docs
    but still doesn't answer all my questions which (AGAIN) are:
    1) What is the real function of the first argument to
    addEventListener? I have not seen a clear explanation anywhere.
    2) Do I need to write my own Event class?
    3) What about dynamic event types that are defined at
    runtime? Are there any pitfalls or risks that arise from using a
    string instead of a predefined constant as the first param to
    addEventListener() ?
    Please stop telling me to read the documentation. I've been
    reading it for days.

  • Dynamic form font color changes after saving

    I have a dynamic form that before the user clicks inside a textfield ghost text appearance is set to red once the user starts typing I have an event set to turn the font to black.
    The problem is, once form is saved and reopened the font color is red instead of black. How can I get the font color to remain black?
    I am thinking that script should be in the PreSave event if so, please provide an example of how it should be written.
    Thanks

    I have several events happening in the text field
    for the ghost text (tool tip) I have set an initialize event: (by the way I did choose the color red for the font in the color picker for the tooltip color)
    this.execEvent("exit");
    this.format.picture.value = "null{' " + this.assist.toolTip.value + " '}";   
    Enter event: (this changes the font to black and bullets appear)this.fontColor + "0,0,0";
    this.font.posture = "normal";
    if(this.rawValue === null)
        this.rawValue = "l ";
    Exit event
    if (this.isNull)
       this.fontColor = "255,0,0,";
       this.fontposture = "italic";

  • How to modify a string (bolt, underlined, font) inside the XML code

    Hi all, I have this code (used inside BI Publisher)
    <?if:INDUSTRY_COMPETENCE_DESCR != ''?> Industry competencies: <?for-each:G_IND_COMP?><?INDUSTRY_COMPETENCE_DESCR?><?end for-each?><?end if?>
    Anyone knows how can I show the string "Industry competencies" bold and underlined ? and also how can I set the format (font style, font dimensions, font colors, etc...) ?
    Regarding the bolt feature I tried the <B> from HTML but it doesn't work.....
    Any help will be appreciated
    Thanks
    Alex

    Hi all, I have this code (used inside BI Publisher)
    <?if:INDUSTRY_COMPETENCE_DESCR != ''?> Industry competencies: <?for-each:G_IND_COMP?><?INDUSTRY_COMPETENCE_DESCR?><?end for-each?><?end if?>
    Anyone knows how can I show the string "Industry competencies" bold and underlined ? and also how can I set the format (font style, font dimensions, font colors, etc...) ?
    Regarding the bolt feature I tried the <B> from HTML but it doesn't work.....
    Any help will be appreciated
    Thanks
    Alex

  • Creating a dynamic style font with live cycle desginer ES 8.2

    Can I control dynamicly the style (Italic) and the weight (bold) of  text in a  dynamic pdf form ( imade it with livecycle designer ES 8.2) that gets its  data from an XMl file.

    Hi,
    A lot of the information you need is in Adobe's scripting guide http://www.adobe.com/go/learn_lc_scriptingReference  Also there is a very useful Adobe guide to Calculations and Scripts (and while it is for version 6 it is still very good because of the way it is laid out) http://partners.adobe.com/public/developer/en/tips/CalcScripts.pdf
    The Javascript could be used in the Layout: Ready event.
    For italic font:
    if (...some test...)
         this.font.posture = "italic";
    else
         this.font.posture = "normal";
    For bold font:
    if (...some test...)
         this.font.weight = "bold";
    else
         this.font.weight = "normal";
    The script will change the font for the complete field. I don't think you can change parts of a field.You can also change font colour and font type (the guides above will help).
    Good luck,
    Niall

  • Dashed underline Font problem

    Hi,
    I create the following font :
    attributes.put(FAMILY, Font.SERIF);
    attributes.put(SIZE, 50);
    attributes.put(INPUT_METHOD_UNDERLINE,UNDERLINE_LOW_DASHED);
    Font f= new Font(attributes);
    myLabel.setFont(selectedFont);
    myLabel.setText("Text");My problem is the dashed line doesn't scale with the font size !
    How to resolve that ?
    Best regards

    My problem is the dashed line doesn't scale with the font size !Well, that's as per the API.
    Single pixel dashed low underline.
    How to resolve that ?Custom painting?
    db
    If you weren't interested, you shouldn't have asked in the first place.
    Edited by: Darryl.Burke on Mar 2, 2009

  • Dynamically changing font - Ugly chars on Win 2000

    Hi,
    I wrote simple class called FontChooser (extends JDialog). It can be "plugged" into any JFrame to change font at runtime. Looks like ordinary font dialog, nothing special.
    The FontChooser itself works (IMHO) just fine but I'm facing a problem: Almost all PLAIN fonts on Windows 2000 (sp4) have several ugly characters. For example Tahoma PLAIN 11 has ugly char '8'.
    Strange is that BOLD fonts are always displayed OK - the ugly things are "covered".
    The only font that's OK is Arial. (Any size, any style.) Brobably because it's the Swing default font.
    Changing the font is done by this method:
    * The method simply iterates through the table of  GUI keys and updates every key whose name ends with "font".
    Thus, FontChooser is not able to deal with different fonts at the same time.
    public void updateFontKeys(FontUIResource font) {
      UIDefaults def = UIManager.getDefaults();
      Enumeration en = def.keys();
      while(en.hasMoreElements()) {
        String key = en.nextElement().toString();
        if(key.toLowerCase().endsWith("font"))
          UIManager.put(key,font);
    // Note: FontUIResource is just a new (Swing)
    // "version" of java.awt.Font.I also tried to change Swing component's font using html
    - instead of changing gui keys - but the result was the
    same :o(
    Any hint will be very appreciated :o) Thanks.

    You can download FontChooser (with a simple demo app) from http://www.volny.cz/dojcland/gui/FontChoosing.zip
    The archive includes binaries, source and javadoc.

  • Extending user collection dynamically

    hello,
    I have folloving code:
    CREATE TYPE T_my_row OID '4711'
    IS OBJECT(field1 varchar2(10), field2 number(10));
    CREATE TYPE TT_my_table OID '0815'
    IS TABLE OF T_my_row;
    declare
    my_table TT_my_table := TT_my_table()
    begin
      for my_value in (select rownum, 'a' as filed1, 2 as field2 from dual) loop
        my_table(my_value.rownum) := T_my_row(my_value.filed1,my_value.filed2);
      end loop;
    end;
    /but this gives me an error:
    ORA-06533: Subscript beyond count.
    I understand that I need to tell how many entries the table may have.
    But how do I do that without providing all rows on initialisation?
    Is there something like my_table TT_my_table := TT_my_table(p_max_row_count=>407) ?
    bye
    TPD

    T.PD wrote:
    I understand that I need to tell how many entries the table may have.
    But how do I do that without providing all rows on initialisation?
    Is there something like my_table TT_my_table := TT_my_table(p_max_row_count=>407) ?No. You can use the +.Extend()+ method to add (null) objects to the collection.
    In your example's case however, it is much simpler to allow PL/SQL to do all the work for you - extending the collection and populating it using a bulk collect.
    E.g.
    select T_My_Row( col1, col2 ) bulk collect into my_table from table where ...
    Of course, you need to be mindful of the size of the collection created. PGA memory is used - and as dedicated server memory (opposed to shared server memory), it is expensive memory. And not to be needlessly wasted.

  • Dynamically load fonts from SWF files

    Hello,
    9. Add code to register the fonts you embedded when the FontSWF is Loaded.
    import flash.text.Font;
    /*You will use the name of the font that was embedded and DF4. For example, in the example below Arial Black was embedded. Notice that underscores are used. These are added to the font name when it is embedded to create the font class name. If you embedded something like Times New Roman, you would use Times_New_Roman_DF4.*/
    Font.registerFont(Arial_Black_DF4);
    This sentences is following document page 6.
    http://download.macromedia.com/pub/labs/textlayout/textlayout_flashcomponent_overview.pdf
    How is a Japanese font?
    example:
    A-OTF Shin Go Pro M
    Hiragino Kaku Gothic Pro W6
    The following are the errors.
    A-OTF_Shin_Go_Pro_M_DF4
    Hiragino_Kaku_Gothic_Pro_W6_DF4
    Best regards,

    Yes, you should be able to create an RSL that has a font in
    it that can be used. See here for a tutorial on RSLs:
    http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=L iveDocs_Parts&file=00001524.html

  • Dynamically set font in a JTable cell

    Hi there,
    i have a JTable, and a JTCombo box containing all the system fonts available. The JTable is made up of my own class called myCell which can be seen below. I have also implemented my own custom renderer. What i would like to do is when the user selects a new system font, the text that is then typed into the JTable to be of that font. If the system font is changed again, i would like any new text to be of the new font, and the old fonts remain the same (i hope that makes sense!) Anyway, im quite stuck about this - i have tried messing around with the cellrenderer but all the text in all the cells changes to the new font. Does anyone know how to do this? many thanks, Rupz
         public myCell(int aRow,int aCol,Object someValue, TreeSet somecells, String aFormula){
              row = aRow;
              col = aCol;
              value = someValue;
              expression = aFormula;
              references = somecells;
         }

    First of all the Java standard for class names us to use upper case characters for the first letter of each word. So your class should be MyCell.
    Now your MyCell class need to keep the Font as one of its properties. Maybe you would override the JTable getCellEditor(...) method such that if the Font property for the cell is null, then set the cell Font to the current default Font. The renderer would then use the Font from the cell when it is non-null.

  • Smartforms-Dynamic Change of Font Size in main window

    Hi Friends,
       How shall I be able to change dynamically the font size in main window of smartform. If the records are more in main window then the layout comes in 2 pages but if less in 1 page. So I want to decrease the font if the records are more to assign it in 1 page.
    Eg : I can print only 10 lines in 1 page of main window, but if the records exceed 10 lines it is going to next page, so I want to shrink the font size to maintain the layout in 1 page.
    Thanks & Regards,
    Somen
    Edited by: Das_SAP on Jun 23, 2009 7:59 AM

    Hi,
    SmartForms does not offer the option to set some characteristics at runtime. You must work with conditions in your form.
    First find out how many records you have in your table
    DESCRIBE TABLE mytable RECORDS sy-tfill.
    You create 2 texts nodes with the text to be output and assign the font and font size to them. Obviouly, one node will have a big font size and the other one a normal font size but both contain the same information and same variables.
    You can now work with an alternative. If the condition (there are many records for a secondpage) is true, assign text node with normal font size to option TRUE and the other text node to FALSE.
    Optionally, every text node has folder CONDITIONS, where you can say
    SY-TFILL >   10 lines  <-- for text node with normal font size
    SY-TFILL <= 10 lines  <-- for text node with big font size

  • Dynamic text boxes, font size issues

    I have created a dynamic text box and an input text box.
    I have produced code that replicates whatever is typed in the
    input box to display in the dynamic box along with a date and time
    stamp once a button is clicked.
    This all works fine, except for the sizes of the fonts. for
    both boxes, i selected font size 10 . The input box is fine,
    however the dynamic box text is huge.
    When i make the dynamic text font smaller, it fits in fine,
    but the input text that is inserted into the dynamic text box comes
    in too big. If i make the input text box font smaller it is
    unreadable when typing it in.
    any soultion to how to make my font consistent. I am assumin
    the problem is because both the text boxes are different sizes,
    however i don't know how to resolve the issue.
    Any help is much appreciated.

    var today_date:Date = new Date();
    var date_str:String =
    (today_date.getDate()+"/"+(today_date.getMonth()+1)+"/"+today_date.getFullYear());
    var my_date:Date = new Date();
    var boat = ""
    btn_send.onPress = function() {
    var today_date:Date = new Date();
    var date_str:String =
    (today_date.getDate()+"/"+(today_date.getMonth()+1)+"/"+today_date.getFullYear());
    var my_date:Date = new Date();
    date_txt = date_str + " " + my_date.getHours() + ":" +
    my_date.getMinutes() + ":" + my_date.getSeconds() + " " + boat;
    the text appears in the dynamic box it just is a mish mash of
    font sizes!!!

Maybe you are looking for

  • Issue in Column NAMES Printing in SQLPLUS

    Hi All, I am connecting to 2 databases through a 10.1.0.4.2 Version of SQLPLUS. 1st Database runs with - 10.2.0.4 Patchset 2nd Database runs with - 10.2.0.1.0 Patchset From both the Databases we are running a long query with columns using Decode funt

  • 9360 Trackpad Help

    Hello. I really need help with my trackpad. There's a problem with the actual pad. Recently the old one messed up, it stopped working completely so I purchased a new one from a seller I bought all my parts off and installed it myself. The trackpad wo

  • Mail not working after installing OX 10.10.1

    Have been dealing with symptoms of the update in mail all day long: -Moving messages to folders results in "cannot move" message.  -Attempts to quit the program do not work, must Force Quit. -Messages won't delete, or allow themselves to be moved. -M

  • Horizontal Scroll bar CSS problem

    I am having some issues with my horizontal scroll bar. I looked up the horizontal scroll properties and I believe I have them correct? What is happening is on my horizontal scroll bar it is giving me up and down arrows instead of left and right and y

  • FB2 memory Errors: where are -vmargs -Xmx and .log?

    I have a workspace that I use to create small example apps. I currently have about 50 apps in one project Often, whan I close that project i get a memory error dialog instructing me to use the command line to modify the-vmargs and -Xmx settings an to