Results 1 to 4 of 4
  1. #1
    billq is offline Member
    Join Date
    Dec 2009
    Posts
    25
    Rep Power
    0

    Default 2 row display with multiple fonts

    I am trying to create a 2 row display for a calculator. I would like to have the top line to be displayed with a small font and the second line with a large font. I am not sure which component will fit the bill. I have been playing with the JTextField and the JTextArea without any luck. Please point me in the correct direction.
    thanks
    bill

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    What information will be in both rows? Will information from the top row overflow into the bottom?

    My thinking here is that you'll probably want to use two components stacked on top of each other. If the text should be editable by the user, then use a JTextFields, and if not, then JLabel. If one is editable and the other not, then use one of each. The other option is a JEditorPane, but that seems like a bit of overkill to me.

  3. #3
    billq is offline Member
    Join Date
    Dec 2009
    Posts
    25
    Rep Power
    0

    Default

    thanks for the reply. I am trying to mimic the behavior of the window 7 calculator. The display will not be editable. When you press the number buttons the display is updated in the lower right hand side of the display. Once the plus sign is pressed the first number is moved to the upper right of the display in a smaller font. The new number appears in the lower right in a bigger font. I thought about 2 labels stacked but there is a very nice gradient backgound on the displaly I would like to achieve.
    thanks
    bill

  4. #4
    JavaJuJitZu is offline Member
    Join Date
    Jan 2010
    Posts
    26
    Rep Power
    0

    Default

    If you dont want two components and still want to have multiple fonts. Fubar Suggested the JEditorPane which is an option.

    Another is a JPanel, where you override the paintComponent method and use the drawString methods of the graphics context. This approach will give you a great deal of control over the visuals, however it comes with a lot of coding with regards to placement.

    What isn't clear to me is why 2 labels is stopping you from achieving a gradient background you would like to achieve. Research the GlassPane and AlphaComposites I think using these should allow you to use 2 labels and still achieve graphical look you are after.
    I don't have windows seven so i'm not exactly sure what you are trying to achieve with the look. If you can post screenshot i may be able to give you more specific information as to how to use the Composites and the glasspane.

Similar Threads

  1. Java Runtime Bad Fonts
    By ayacopino in forum New To Java
    Replies: 3
    Last Post: 01-19-2010, 04:23 PM
  2. PdfBox and barcode fonts
    By alexre2005 in forum New To Java
    Replies: 5
    Last Post: 12-03-2009, 02:59 PM
  3. Changing the default fonts via UIManager
    By fletcher in forum AWT / Swing
    Replies: 4
    Last Post: 09-26-2009, 06:48 PM
  4. Fonts (Changing Fonts and Color's)
    By dbashby in forum New To Java
    Replies: 10
    Last Post: 04-06-2009, 01:32 AM
  5. how to get raw image data for fonts
    By Nicholas Jordan in forum Java 2D
    Replies: 8
    Last Post: 04-05-2009, 06:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •