Results 1 to 4 of 4
  1. #1
    Jarob22 is offline Member
    Join Date
    Mar 2011
    Posts
    12
    Rep Power
    0

    Default Putting labels on the side of a graph

    Hey,

    I'm just finishing off a GUI on which are some graphs. These are drawn via the awt and awt.geom libraries and will take input data.

    The problem I'm having is that I can get a label which says 0 on the bottom left of the graph at the axis, but I can't seem to get a label on the top left which would be the maximum value. I've tried using all the anchor points for the BorderLayout manager which is what I'm using, but the label either goes off the frame or overlaps the whole graph causing it to disappear.

    I have included the two classes which you will need to run and see the graph, just run the HidableGraphingData class (not actually how it's done in the real GUI, the main method there is just for testing purposes).

    To clarify - I want to make a label at the top left of the graph which would be an upper value of the graph, but the layout manager won't let me.

    Thanks in advance,

    James
    Attached Files Attached Files

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

    Default

    Rather than use a layout manager to place it, why not draw it directly onto the JPanel from within its paintComponent method using the the Graphics object's drawString method?

  3. #3
    Jarob22 is offline Member
    Join Date
    Mar 2011
    Posts
    12
    Rep Power
    0

    Default

    You sir, are a genius.

    <33

    Thanks! :D

    Edit: +rep'd you :)

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

Similar Threads

  1. Printing labels to A4
    By eggy524 in forum New To Java
    Replies: 3
    Last Post: 09-23-2010, 04:53 PM
  2. Replies: 1
    Last Post: 03-20-2010, 07:03 PM
  3. Putting a graph on another JPanel in another JFrame
    By thestarncy in forum AWT / Swing
    Replies: 10
    Last Post: 12-31-2009, 04:45 PM
  4. size och swt labels
    By larsk in forum SWT / JFace
    Replies: 0
    Last Post: 10-04-2009, 12:01 PM
  5. Deploy Jar Side By Side
    By Adrian in forum Eclipse
    Replies: 0
    Last Post: 04-11-2008, 02:09 PM

Posting Permissions

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