Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7447011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:29:16+00:00 2026-05-29T12:29:16+00:00

I want to change the appearance of a Matlab pushbutton with Java. For it,

  • 0

I want to change the appearance of a Matlab pushbutton with Java. For it, I use the application Findjobj. However, because of I do not know Java, I have troubles to use Java classes properly that I need to get my button has rounded corners. Based on the information found here), I have tried to set up the button with the class BorderFactory:

hButton = uicontrol('string','click me!');
jButton = findjobj(hButton);
jButton.setCursor(java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton.setBorder(BorderFactory.createLineBorder(red,1,true));

But this does not work. I got the following error message:

??? Undefined function or variable 'red'.

    Error in ==> de at 4
    jButton.setBorder(BorderFactory.createLineBorder(red,1,true));

EDIT: I realize I forgot to include the Java classes for color and LineBorder. After fixing it, the code looks like this:

import java.awt.Color;
import javax.swing.border.LineBorder;
hButton = uicontrol('Style','pushbutton','String','click me!',...
    'Units','normalized','Position',[0.156 0.64 0.688 0.1],'FontSize',9,...
    'ForegroundColor','w','BackgroundColor','k');
jButton = findjobj(hButton);
jButton.setCursor(java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton.setBorder(LineBorder(Color.white,5,true));

However, the result still be unpleased for me. Here is the final appearance. I can get the corners to be rounded.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:29:17+00:00Added an answer on May 29, 2026 at 12:29 pm

    If you want rounded buttons, you’ll have to use a Look & Feel whose button UI delegate draws rounded buttons. Examples include com.apple.laf.AquaButtonUI, illustrated here, and javax.swing.plaf.synth.SynthLookAndFeel, shown here. You can also implement your own ButtonUI and Border, as shown here, but you’ll have decide if it’s worth the effort.

    Addendum: Looking at this related Matlab question and the relevant Swing tutorial, note that “If you are going to set the L&F, you should do it as the very first step in your application.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three main things I want to change with the appearance of a
I want to be able to change the appearance of the mouse cursor as
I want to change the text of a radio button (HTML element), not an
I want to change member of structure under double pointer. Do you know how?
How can i change the appearance (not the color) of a scrollbar within a
I want to override isEnabled() method in java.awt.Component and use it with a JTextArea.
I want to change the appearance of the default editor parts, and am a
I want to change the appearance location of top menu in only home page.
UIStepper is very convenient but I want to change the appearance of it, I
i have pagination links like 1,2,3,4...am trying to change appearance of current page using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.