How do I indent a button?

  • 0
    Hello everyone.
    Can you please tell me how to indent a button?
    analog paddin? google many solutions like
    setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));

    or
    JBtn.setMargin (new Insets (5,5,10,10));
    but they add an internal lack, but an external one is needed.
    I do not want to just resort to the option of creating a JPanel, adding a button to it and setting indents
    Thank you
    Java Cora Allison, Jan 8, 2020

  • 1 Answers
  • 0
    What you need is not an analogue of padding (this is just an internal absence), but an analogue of margin (external padding).

    Here stackoverflow.com/questions/9565760/java-jpanel-with-margins-and-jtextarea-inside describes two options for implementing what you need with links to Oracle's documentation. Easily google examples by name.


    P.S. assuming you are familiar with css, you might want to take a look at javaFX.
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!