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 8066437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:59:42+00:00 2026-06-05T11:59:42+00:00

So I am trying to create a custom LookAndFeel using java synth and I

  • 0

So I am trying to create a custom LookAndFeel using java synth and I am having problems binding a custom button. (the Exit Button has a different look).

Here are the buttons from my synth file:

<!-- Button -->

<style id="buttonStyle">
    <property key="Button.textShiftOffset" type="integer" value="1"/>
    <insets top="2" left="2" right="2" bottom="2"/>
    <state>
        <color value="#000000" type="BACKGROUND"/>
        <imagePainter method="buttonBackground" path="/rstk/resources/pictures/parts/button.jpg" sourceInsets="2 2 2 2"/>   
    </state>
    <state value="PRESSED">
        <color value="#9BC3B1" type="BACKGROUND"/>
        <imagePainter method="buttonBackground" path="/rstk/resources/pictures/parts/button_p.jpg" sourceInsets="2 2 2 2"/>         
    </state>
     <state value="MOUSE_OVER">
        <color value="#9BC3B1" type="BACKGROUND"/>
        <imagePainter method="buttonBackground" path="/rstk/resources/pictures/parts/button_h.jpg" sourceInsets="2 2 2 2"/>         
    </state>
</style>
<bind style="buttonStyle" type="region" key="Button"/>


<!-- Exit Button -->

<style id="exitStyle">
    <property key="Button.textShiftOffset" type="integer" value="1"/>
    <insets top="1" left="1" right="1" bottom="1"/>
    <state>
        <imagePainter method="buttonBackground" path="/rstk/resources/pictures/parts/exit.jpg" sourceInsets="2 2 2 2"/> 
    </state>
    <state value="PRESSED">
        <color value="#9BC3B1" type="BACKGROUND"/>
        <imagePainter method="buttonBackground" path="/rstk/resources/pictures/parts/exit_p.jpg" sourceInsets="2 2 2 2"/>           
    </state>
    <state value="MOUSE_OVER">
        <color value="#9BC3B1" type="BACKGROUND"/>
        <imagePainter method="buttonBackground" path="/rstk/resources/pictures/parts/exit_h.jpg" sourceInsets="2 2 2 2"/>           
    </state>
</style>
<bind style="exitStyle" type="region" key="Exit"/>

Here is the code that creates the button.

JButton exit = new JButton("Exit");
        exit.setName("exit");

I’ve tried taking out the normal button style, so that all I would have would be custom buttons, however that doesn’t work. I also tried making the buttonStyle have nothing in it, but that didn’t work, it just picked up the overall style:

    <style id="backingStyle"> 
    <opaque value="TRUE"/>
    <font name="Dialog" size="11"/>
    <state>
      <color value="#2B271C" type="BACKGROUND"/>
      <color value="YELLOW" type="FOREGROUND"/>
    </state>
  </style>
  <bind style="backingStyle" type="region" key=".*"/>
  • 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-06-05T11:59:44+00:00Added an answer on June 5, 2026 at 11:59 am

    I believe your problem is due to the fact that there is no Region called Exit. All regions should come from the javax.swing.plaf.synth.Region class. The API will tell you what to use for binding to that region http://docs.oracle.com/javase/6/docs/api/javax/swing/plaf/synth/Region.html

    But if you want to have a special button that looks different than your standard synth drawn button I find the easiest way is to bind to “name” not “region”. Create a simple class that extends JButton. You can name it ExitButton. You don’t even need to override any methods. The XML file will then bind a style to that class name. Then whenever you want to use that style button create an ExitButton object instead of a JButton (Though it will act the same and have the same methods it will look different per the XML binding).

    For the XML file you will then bind it as follows:

    <!-- Exit Button -->
    
    <style id="exitStyle">
      <property key="Button.textShiftOffset" type="integer" value="1"/>
      <insets top="1" left="1" right="1" bottom="1"/>
      <state>
        <imagePainter method="buttonBackground" path="/rstk/resources/pictures/parts/exit.jpg" sourceInsets="2 2 2 2"/> 
      </state>
      <state value="PRESSED">
        <color value="#9BC3B1" type="BACKGROUND"/>
        <imagePainter method="buttonBackground" path="/rstk/resources/pictures/parts/exit_p.jpg" sourceInsets="2 2 2 2"/>           
      </state>
      <state value="MOUSE_OVER">
        <color value="#9BC3B1" type="BACKGROUND"/>
        <imagePainter method="buttonBackground" path="/rstk/resources/pictures/parts/exit_h.jpg" sourceInsets="2 2 2 2"/>           
      </state>
    </style>
    <bind style="exitStyle" type="name" key="ExitButton"/>
    

    Note that the only difference is type=”name and key=”ExitButton” (or whatever you choose to name your class that extends JButton). Also the value of the key must match the name of the class you created and want to use for this style of button.

    Hope this helps.

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

Sidebar

Related Questions

I am trying to create a custom html button on my page using this
I'm trying to create a custom usercontrol that acts like a button, but i
I am trying to create a custom table using custom module. I have been
I am trying to create a custom cell for my UITableView. I am using
I'm trying to create custom attributes to my button but I dont know which
I'm trying to create a custom search interface for Apache Solr using Drupal ,
I am trying to create custom Check Box button image. After some research, I
I am trying to create a custom List Adapter which has an Image for
I am trying to create custom array indexed from 1 using subscript operator. Getting
i am trying to create a custom solution for a client using their prior

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.