Swing Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shanaj
    New Member
    • Jan 2007
    • 51

    Swing Button

    hello

    Do u Know how to change the border of a swing Button to rounded ends
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Quoted from TechInterviews
    Answer: there’s 2 ways. The first thing is to know that a JButton’s edges are drawn by a Border. so you can override the Button’s paintComponent( Graphics) method and draw a circle or rounded rectangle (whatever), and turn off the border. Or you can create a custom border that draws a circle or rounded rectangle around any component and set the button’s border to it.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Also see this tech tip. Note however that the article is old so it may use deprecated methods - I've not checked.

      Comment

      • Shanaj
        New Member
        • Jan 2007
        • 51

        #4
        Originally posted by acoder
        Quoted from TechInterviews

        please reply with that code

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by Shanaj
          please reply with that code
          There was no code - it was just a tip to point you in the right direction.

          Have you checked the link that I gave above?

          Comment

          • Soujiro
            New Member
            • Jan 2007
            • 35

            #6
            hmm.. the main of the class tells everything

            Comment

            Working...