Solved

Custom interface design

Posted on 2004-10-26
171 Views
Last Modified: 2010-03-31
I'm in the process of learning Java (my first forray into object oriented programming).  I took a program that served a need of mine but was very limited in function, decompiled it, modified it and added a lot of additional options and features.  Everything with the program is working great, but I want to change the look and feel of it.  Currently it looks like this:

http://thelcrp.net/images/PControl.jpg

I want it to look more like this mock-up I've created:

http://thelcrp.net/images/PControl4.jpg

I'm sure there is not a quick and easy answer to this.  So all I'm really expecting is to be pointed in the right direction and maybe address a couple follow-up questions.
0
Question by:Heathicus
    11 Comments
     
    LVL 2

    Expert Comment

    by:Breadstick
    The simplest solution in your case would be to construct the desired interface with normal JButton's, then set Icon's for the button's, with setIcon(), setPressedIcon(), and setRolloverIcon().

    Another option would be to draw all of your components using Java2D, and then write a MouseListener, and MouseMotionListener to handle mouse movement and clicks.
    0
     
    LVL 6

    Expert Comment

    by:expertmb
    it is possible to have that L&F
    0
     
    LVL 6

    Assisted Solution

    by:expertmb
    0
     
    LVL 15

    Accepted Solution

    by:
    Hi;

    I see what you need :

    1. Create a frame using JWindow instead of JFrame.
    2. Add the background image to JWindow.
    3. Customize your buttons by designing the image.
    4. Use the codes bellow for customizing it :

      JButton button = new JButton(new ImageIcon("x1.gif"));
      button.setPressedIcon(new ImageIcon("x2.gif"));
      button.setRolloverIcon(new ImageIcon("x3.gif"));
      button.setDisabledIcon(new ImageIcon("x1.gif"));
      button.setFocusPainted(false);
      button.setBorderPainted(false);
      button.setContentAreaFilled(false);
      button.setMargin(new Insets(0,0,0,0));

    5. Use a good layout to adjust to your needs, like border and grid.
    6. A link that can give you help is :

    http://www.experts-exchange.com/Q_20639614.html

    Hope that helps . . .
    Javatm
    0
     
    LVL 15

    Expert Comment

    by:Javatm
    If incase that you dont know how to put a background or paint an image to a JWindow.
    Here is an example on JFrame but can also be use for JWindow :

    http://www.experts-exchange.com/Q_20847106.html
    0
     
    LVL 1

    Author Comment

    by:Heathicus
    Thanks for the help.  I haven't figure out the JWindow yet, but I'm making progress using JFrame.

    Focusing on just one jpanel for now (the Source panel in my mockup) I have my buttons added with different versions for their different states, and I've even suppressed the focus border and added tooltips.  Everything functions correctly.  But I have two more questions:

    How do I limit the button area to just the edges of the .jpg file?  For instance, if I make a round button (or some other shape, such as the arrows in my mockup), how do I limit the button area to just that image instead of the rectangle around it?  Should I make the icon files as transparent .gifs instead of .jpgs?

    How can I set specific size dimensions and window loactions on the jpanels (or even individual buttons) to get the exact layout I want?
    0
     
    LVL 15

    Expert Comment

    by:Javatm
    > How do I limit the button area to just the edges of the .jpg file?
    Check-out my codes above it'll limit the edges depending on how it was made.

    >Should I make the icon files as transparent .gifs instead of .jpgs?
    Yes you can also do that.

    > How can I set specific size dimensions and window loactions on the jpanels (or even individual buttons) to get the exact layout I want?
    Exactly means you have to plan 1st. 2nd know what layout you would want to use. For Layout the hardest would be GridbagLayout. Its
    the most specific layout but surely the hardest to implement. BorderLayout and GridLayout combination is what I use.

    Here is a tutorial :
    http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html

    Hope that helps .  . .
    Javatm
    0
     
    LVL 15

    Expert Comment

    by:Javatm
    What happend ???
    0
     
    LVL 1

    Author Comment

    by:Heathicus
    Sorry for the silence.  I read through the tutorial you linked to and found it very educational.  I began experimenting with various combinations (GridBagLayout for general layout, and others for the specific sections) but had to set the project aside a few days ago.  I hope to put my focus back on it within the next couple days.  But I will clean this question up soon.
    0
     
    LVL 1

    Author Comment

    by:Heathicus
    I still haven't had much time to work on my program, but I want to clean this question up.  I keep trying to get back to work on it before it becomes pushed aside for good, but so far no luck.  I am taking vacation next week and I'm taking my laptop for the sole purpose of working on this.  I'm sure I'll have more questions when I get back.

    I'm splitting the points and giving 100 to Javatm for all of his help (that last link was particularly helpful), and 25 to expertmb as the link he provided was very helpful as well.
    0
     
    LVL 15

    Expert Comment

    by:Javatm
    Thanks for accepting and hoping to help you more in the future.

    http://freewebs.com/cube-j
    Friend : Javatm
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    1. Package the applet into a JAR file. The applet must be in a JAR file before a certificate can be attached to it. Use the jar JDK utility. If the applet was previously referenced with the help of a codebase attribute in  tag, replace the codebase …
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now