Jul 7, 2008

How To Create Java Button Or Frame - to be customized

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP
Pages: 1, 2

free web hosting

How To Create Java Button Or Frame - to be customized

negativezero
hi to all!!!!
just like to ask if it would be possible if i could make a custom button or frame in java.
i got tired of using the build infeatures in java.
i would like to create my own dessign of button or frame..
can it be possible!!! biggrin.gif

thank!!!! laugh.gif

Notice from BuffaloHELP:
New Help In! is NOT a descriptive topic title. Next time you decide not to follow the posting rules, you will be issued a week long ban.

Reply

bjrn
QUOTE(negativezero @ Jul 29 2005, 12:11 PM)
hi to all!!!!
just like to ask if it would be possible if i could make a custom button or frame in java.
i got tired of using the build infeatures in java.
i would like to create my own dessign of button or frame..
can it be possible!!! biggrin.gif

I'm not really sure what it is you want.

Java has a "look and feel" (LAF) as they call it, which can be switched. Normal Swing apps default to a certain look and feel which usually isn't too good looking. However you can change the look and feel used.

If you do mean the "look and feel", then the answer is that you can pick your own look and feel and plug it into your java app. You will have to bundle the LAF jar with whatever you are making obviously, because otherwise people will just get the "standard" look and feel.

Just google around for 'java "look and feel"' and you should be able to find plenty. Thow in the word "tutorial" and you'll no doubt find out exactly how to make your app use the look and feel you want it to.



But I'm not sure that is what you meant, if you meant something else, just say so smile.gif

 

 

 


Reply

wild20
You can use a code that links to a picture or button link. But the image has to be uploaded onto you database. Just depends on what you want to do. I use html to make buttons and upload the pics to my database. That is the best way to do it in my ipinion. Just use a webmaster database and search for the answer. That is what I do. Sorry I couldn't be of more help. Have you tried a tutorial? You can always use those. Just use a search engine. That should give you the best answer. A tutorial that is.

Reply

beeseven
You're being kind of vague, so I'm not exactly sure what you mean, but here are some neat things you can do with a JButton:

Let's assume we have a JButton called myButton.

This changes the font:
CODE
String name = "Serif"; //"Serif", "SansSerif", "Monospaced", or a font name
int style = Font.ITALIC //Font.ITALIC, Font.BOLD, or Font.BOLD | Font.ITALIC
int size = 14 //any number size
myButton.setFont(new Font(name, style, size));

Change colors:
CODE
myButton.setForeground(new Color(255,0,0)); //changes font color (in this case makes it red)
myButton.setBackground(new Color(0,0,255)); //changes background color (in this case blue)

Disable, reenable:
CODE
myButton.setEnabled(false);
myButton.setEnabled(true);

Add an image to display if it's enabled, or disabled:
CODE
ImageIcon ico = new ImageIcon("picture.gif"); //any image
myButton.setIcon(ico);
ImageIcon ico2 = new ImageIcon("otherpicture.gif");
myButton.setDisabledIcon(ico2);

Make the button plain text (but still a button):
CODE
button.setBorderPainted(false);
DDT TJ 08: button.setFocusPainted(false);

Reply

leiaah
I'm not quite sure what you mean but I've dug up a few java projects in the past and I saw this code. To change the over-all look-and feel of your buttons (including the whole frame) just call these functions like this:
CODE
WindowUtilities.setJavaLookAndFeel();



CODE
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class WindowUtilities {

 //WINDOWS (or whatever your OS is) LOOK -->  WINDOWS BUTTONS

 public static void setNativeLookAndFeel() {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch(Exception e) {
     System.out.println("Error setting native LAF: " + e);
   }
 }

 //JAVA LOOK -->  JAVA BUTTONS

 public static void setJavaLookAndFeel() {
   try {
     UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
   } catch(Exception e) {
     System.out.println("Error setting Java LAF: " + e);
   }
 }

  //DARK RED COLOR-->  COOLER-LOOKING BUTTONS!

 public static void setMotifLookAndFeel() {
   try {
     UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
   } catch(Exception e) {
     System.out.println("Error setting Motif LAF: " + e);
   }
 }

}


Now if you only need to change the buttons You can try to include an image in your button. By doing this:
CODE
buttonName.setIcon(new ImageIcon("images/btn1.gif"));

Reply

JField
u can extend from JButton and set your wishes in constructer than whenever u want your button u can create it

class MyButton extends JButton{
public MyButton(){
write your wishes here

}

}

//then create it anywhere

new MyButton();

Reply

spieleforum
QUOTE(JField @ Jul 20 2006, 02:44 PM) *

u can extend from JButton and set your wishes in constructer than whenever u want your button u can create it

class MyButton extends JButton{
public MyButton(){
write your wishes here

}

}

//then create it anywhere

new MyButton();

Yes i would Prefer this way because its much easier than doing a own Look and Feel but when you create a own look and Feel you can change the Design of all Buttons in you Programm even the Buttons that are used in the programm bevore you created the new Look and Feel

i have a question too
he wanted to set up a background image to his new Button how can i do this? when i extend From "JButton" ?

Reply

salamangkero
QUOTE(spieleforum @ Sep 3 2006, 11:32 PM) *
i have a question too
he wanted to set up a background image to his new Button how can i do this? when i extend From "JButton" ?


Ahh, subclassing, one of my favorite custom component strategy. To use background images, you probably have to mess with the void paint(Graphics g) method. Just draw the image before drawing everything else. happy.gif

Reply

Oleyum
QUOTE(wild20 @ Aug 1 2005, 06:30 PM) *

You can use a code that links to a picture or button link. But the image has to be uploaded onto you database. Just depends on what you want to do. I use html to make buttons and upload the pics to my database. That is the best way to do it in my ipinion. Just use a webmaster database and search for the answer. That is what I do. Sorry I couldn't be of more help. Have you tried a tutorial? You can always use those. Just use a search engine. That should give you the best answer. A tutorial that is.


Hi ,what did you meant when u said that u upload pics on database? Cuz i have same aproach i build buttons in html but only problem is i dunno how to upload them to page.If i try "paste code" in dreamweaver my page becoms all screwed up :-) Ty

Reply

githoko
What I have included below is code for a custom frame. The essentail thing about it is that by using the method setUndecorated you are able to remove the borders and the close and minimize buttons that come automatically when you call the constructor for JFrame. What this then allows you to do is to essentially have a panel as in a normal JPanel, so long as you remember to add to the container object. The customizations that you can do to it are exactly as with the JPanel. The only thing about this is that it is costly. Because the buttons that you add are going to have to have action listeners that allow them the perform the functionality of the buttons that you have removed. Also the frame does not move as normally when you press the mouse and move it on top of it. This the JPanel in this case "p" will have to have a mouse listener to capture mouse pressed events and a mouse motion listener to listen to drag events.

CODE

/*
* CustomFrame.java
*
* Created on January 5, 2007, 6:21 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package customframe;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.*;
/**
*
* @author P1249
*/
public class CustomFrame extends JFrame{
    
    /** Creates a new instance of CustomFrame */
    public CustomFrame() {
        
        int h = 50;
        
        int h1 = h - 10;
        
        int w = h;
        
        this.setUndecorated(true);
        
        setSize(500,500);
        
        Container container = getContentPane();
        
        JPanel p = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        
        p.setBackground(new Color(200,200,150));
        
        p.setPreferredSize(new Dimension(500,h));
        
        JButton button_1 = new JButton("_");
        
        button_1.setPreferredSize(new Dimension(w,h1));
        
        p.add(button_1);
        
        JButton button_2 = new JButton("x");
        
        button_2.setPreferredSize(new Dimension(w,h1));
        
        p.add(button_2);
        
        container.add(p,"North");
        
        setVisible(true);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
        new CustomFrame();
        
    }
    
}


Notice from saint-michael:
how code has to be placed in either the code bb tag or codebox bb tag.

Reply

Latest Entries

iGuest
more text in dialog box
How To Create Java Button Or Frame

I want to create the dialog box that will accept the userid and password from user check it and go to other form by using dialog box not frame.

-question by salish

Reply

iGuest
How to remove the maximize button from the frame or to set a fixed size for a frame at the center of the monitor with a fixed size

-reply by salish

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Recent Queries:-
  1. add to frame at front button in java - 2.29 hr back.
  2. java how change color button - 5.71 hr back.
  3. jbutton font color - 5.92 hr back.
  4. close frame java by button - 7.25 hr back.
  5. add button to frame java - 7.68 hr back.
  6. open created jframe from button - 9.67 hr back.
  7. firefox gif image for jbutton - 20.09 hr back.
Similar Topics

Keywords : create, java, button, frame, customized

  1. Learn Java Programming Language Online Step By Step
    (0)
  2. Java Object[][] Help
    (0)
    I'm having some issues with working with objects . I get an index out of bounds ex.
    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 heres how
    I'm using it ---------------------------- Object contestants = new Object {}; contestants
    = "test"; any ideas appreciated. Do I need to specify the initial size on creation or something?
    It seems I answered my own question I gave it an inital size then I was able to add things. But is
    there a way I can add to it on the fly without knowing its require maximum size?....
  3. Java Vs Javascript
    (11)
    I thought they were completely different things. Surely javascript should be seperated from the rest....
  4. Java Or C++
    (2)
    Many having tell me to make my MMORPG in java leads me to agree, But I'm not sure truly is it
    not yet easier, but yet the outcome of programming an MMORPG in java will make it fail or succeed
    more then one in C+= I've learned a lot of variables in javascript, and I don't think that
    java would be too bad either. My true question is, is those who use these languages, which seems
    to give better outcome, and which seems to be more in ease. Regards -PCessna....
  5. Java Applet Query
    (1)
    Hey there, I have made an applet that shows images moving about the screen. I have pause/resume
    buttons that work. But i've noticed that when the applet is interuppted by something i.e moving
    another window over it, it will automatically repaint. My question is how can I stop this? How can
    I make it so that the only time that paint is called is when I want it to be called? Thanks in
    advance!....
  6. Circular Movment/animation In Java?
    (6)
    Hey there guys! How would i go about making an object move about a fixed point for a java
    applet? Thanks in advance guys! Regards, Rod....
  7. Kill Frame
    (2)
    Hello, I'm not really sure it this can be done with javascript or not but what i would like
    to do is prevent my html pages from beening showed in frames. i know this can be done as i have seen
    it done before but i dont know how to do it. one site that gives this option is co.nr when you
    sign up for a short domain with them they give you the option of do you want killframe to be on, and
    if you select yes the page will not be able to be show in a frame. so if some one knows how to do
    this could they please tell me. Thanks....
  8. Java Part 1
    (2)
    The HTML <script> tag is used to insert a JavaScript into an HTML page. Examples Write text
    with Javascript - http://www.w3schools.com/js/tryit.asp?filename=tryjs_text The example
    demonstrates how to use JavaScript to write text on a web page. Write HTML with Javascript -
    http://www.w3schools.com/js/tryit.asp?file...ryjs_formattext The example demonstrates how to use
    JavaScript to write HTML tags on a web page. How to Put a JavaScript Into an HTML Page CODE
    <html> <body> [color=red]<script type="text/javascript"....
  9. Java In A High School Software Design Course
    Is it good? (5)
    Hi, I'm doing a course called Software Design and Development for HSC in a high school in
    Australia. HSC is basically the courses you do that you get assessed on for University entrance. I
    haven't really done programming before, although I've seen source code and can decipher it
    and make small changes. I am also quite good with the general use of computers. One of the major
    projects we will do in the course is the making of a game (although it's not just game-making
    that we do. We also have to develop a software solution package, although I'm not su....
  10. Beginning Java
    where to start (10)
    does anyone know of any good websites with free java tutorials for people without a lot of prior
    coding experience? i've read some tutorials, but every one i read starts making references to C
    and C++... well i don't know either of those so it gets really really confusing really really
    fast. ive downloaded the sdk but that is it.... i know a pretty good amount of php and a tiny bit of
    perl but those are procedural languages so i dont know if they even helpe me at all with an OOP
    language like java.....
  11. Java Iterator Help
    I need help with a method using iterator (2)
    /** * Remove from the club's collection all members who * joined in the given month,
    and return them stored * in a sparate collection object. * @param month The month of the
    membership. * @param year The year of the membership. * @return The number of members.
    */ public ArrayList purge(int month, int year) { if(month >= 1 && month
    { Iterator it = members.iterator(); ArrayList purged;
    purged = new ArrayList(); int counter = 0; wh....
  12. Java Exercise Help
    I need help to understand this question (2)
    Ok at my Uni they teach you OOP with java, They used to do with C++ i believe but swiched to java
    because its easier to teach people OOP with java apparently. Anyway I've been working on some
    exercises with java (book is 'objects first with java'). I've got this one exercise
    which I cant understand. QUOTE Exercise 4.29 Rewrite getLot so that it does not rely on a
    lot with a particular number being stored at index (number - 1) in the collection. For instance,
    if lot number 2 has been removed, then lot number 3 will have been moved from index 2 ....
  13. Helpful Registry Edit For Java Programmers
    Command Prompt on right click menu (2)
    With this registry edit you can easily open the current folder in prompt without going through any
    Change Directory commands (cd). This is useful for people like me who are programming in JAVA, and
    every time to create class files and test them I have a diificult time just entering the commands in
    Prompt. But if you don't want to use this registry edit you can create the directory in
    C:\ drive like C:\files so you have to navigate very little in prompt. If you are
    experienced in regedit you can do it yourself shown below OR download the attachment and app....
  14. Which Is The Best Java Web Framework?
    JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket (0)
    JSF Pros: Java EE Standard - lots of demand and jobs Fast and easy to develop with
    initially Lots of component libraries Cons: Tag soup for JSPs Doesn't play well with REST
    or Security No single source for implementation Spring MVC Pros: Lifecyle for
    overriding binding, validation, etc. Integrates with many view options seamlessly: JSP/JSTL, Tiles,
    Velocity, FreeMarker, Excel, PDF Inversion of Control makes it easy to test Cons: Configuration
    intensive - lots of XML Almost too flexible - no common parent Controller No built-in Aja....
  15. Help Deploying Java
    (0)
    Hi i just registered to this site. can any1 tell me how to deploy a java app here? i use weblogic
    server on my local machine. thanks Abhishek.....
  16. Text Image Java Problem
    How to include text and image in some scrollable container? (1)
    Hello everyone, I am just writing some kind of text editor as practice for some school project and I
    have come to certain point where I can not solve certain problem. I wanted to make it available
    for people to insert images but I cannot figure how to combine images and text and which container
    should I use. I am working in Java and using swing. Also I would like to say that this content
    should be scrollable. So if anyone knows something about this and could be able to help me thanks in
    advance. Everyone opinion is accepted.....
  17. I Want To Start Java From A-0
    (6)
    Hello everyBody, I am very interested to learn that programming language which jave, however, I
    just hear about it and I made some search but that seems to me very complicated, so I want some one
    to leads me to the right way to start that beautiful programming languge. Please tell me what are
    the avilable free software that I can download and some pdf books if you can.
    I will be very greatful, if you help. thank you for reading.....
  18. I Need Help With Java
    (3)
    I dont have much knowlege with java yet. Im a php programer not a java programer but i want to learn
    java and i need this coding to correct so that i can carry on my learning of java. So please some
    one just take some time to help me. Heres what i need to do. QUOTE An incoming request for a
    specific resource, identified by an URI, must be dispatched to the appropriate handler according to
    the server configuration which maps URIs to request handlers. 'HandlerFactory.getHandler'
    must be implemented: CODE public class HandlerFactory {   public String get....
  19. Jsp Or Java Chat Script Like Mig33
    (4)
    so most of you guys know mig33. its a wap application,probaly java.most kindly to be java. does
    anyone have java knowlege or knows where i can get a chat script like mig33? i also know this server
    supports jsp so im planing to use it for my application. i was hosted here last year but moved
    because i found a better host. now im back just to use the jsp on this server. Im planing to run
    chat applictions so if any one wants to help me in my project let me know.....
  20. Online Purchasing
    online purchasing using java, jsp, sql (1)
    does anybody have a readymade java project titled online purchasing? if u have, pls let me know.....
  21. Concerns On Ajax With Java
    (3)
    Source article from Sun: http://java.sun.com/developer/technicalArticles/J2EE/AJAX/ Well, from
    this article, it shows that Ajax can be achieved with Java using Java Servlets or JSP's. For
    those who don't know what AJAX is, it's an object in Javascript technology that allows for
    instant communication between client-side and server-side. It's like changing a page's
    content without having to reload the whole page. Let's move on... Now when I looked at the JSP
    source code, the servlet's function was to simply validate a text and send back a r....
  22. The Power Of Java
    the best application that shows java features (14)
    Java technology has various usage from mobile applications to Enterprise applications. I think the
    power of Java technology in web applications and applets is showed in "meez.com" where u can create
    your own 3d avatars. /rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0"
    alt="rolleyes.gif" />....
  23. Problem With Java Script Popup Form
    Doesnt work in Safari (1)
    This code wont work in Safari, but works fine in Firefox 2. Can someone help. The error pops up
    however. It just doesn't do anything unless you dont pick one and then it says Pick a Windows
    tweak, but if you DO pick one it doesnt even try to load anything. Everything you see below is
    everything inside my PHP Include. If you would like to view my actual site it's
    http://boozkerstweaks.trap17.com There might be PHP errors and stuff right now, but i am working on
    those, but this i can not get. CODE <td  valign="top" class="right">
       ....
  24. What's The Relationship Between Javascript And Java
    are they the same or different (5)
    I think most of you always confuse about java and javascript .So I make this topic to talk about it.
    Javascript and Java ,they have the same first four letter. Java and Javascript is the two language
    is very popular in the web world.Java is the general-purpose programming language that you can
    create an application or an applet.Javascript is a script language that looks sort of like java;with
    it you can do various nifty things in web pages.They are independent languages ,used for different
    purposes.If you are interesting in creating a website you should learn how to w....
  25. Java Helpdesk
    All your queries regarding Java Programming goes here. (8)
    Hellow friends, I am creating this thread for all queries and suggestions related to java coding. If
    you face any problem, post it here, and others who have a solution can post the reply here. Hope it
    helps the users.....
  26. Ruby - Better Programming Language Than Java And C#?
    Ruby is an object-oriented, meta-programming language that has many de (3)
    hey all i read this very intresting and intriguing article and i thought i should share it here..
    find example codes in the attached file. cheerz! saint Ruby —A Diamond of a Programming
    Language? QUOTE Have you heard about Ruby? It seems to be a popular topic in software
    development circles today. This language came to my attention at a Java conference last spring,
    where gentlemen like Bruce Tate (author of Bitter Java and Better, Faster, Lighter Java), Dave
    Thomas (Pragmatic Programmer: From Journeyman to Master), and others were all talking about Ruby and....
  27. Java Basic Program Guidance
    (6)
    aving some problems taking in the Java at Uni, Was wondering if anyone could shine some light on it
    for me. My task is to write a program that will ask you to enter 2 words. the program will then
    print out both words on one line. However the words will be seperated by dots that will make the
    total length of the line 40. so if your first word was turtle and the second was abc, the output
    would be turtle...............................abc The program should check for certain conditions:
    1. a word can not be longer than 37 characters; 2. there must always be atlest 2 do....
  28. [help] Java Script: Window.open
    Works with Firefox, not IE (8)
    CODE <HEAD> var popUpWin=0; function popUpWindow(URLStr) {
     if(popUpWin)  {    if(!popUpWin.closed) popUpWin.close();  }
     popUpWin = open(URLStr, 'GunBound Tactics: Screenshots',
    'width=820,height=550,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,top=90,left=90')
    ;; } </HEAD> <BODY> <a
    href="javascript:popUpWindow('/f11/clipped.php');"><b>Clips&
    #60;/b></a> This is a script for opening a new window. It works ....
  29. Java Script Drop Down Menu With Css
    - a full code for a dynamic drop down (2)
    Introduction This is a code that I use to dynamically create the drop down menus. First, you have
    to edit the following code and put it in your Javascript. Notice : /*** SET BUTTON'S FOLDER HERE
    ***/. Edit that to your folder. Also, the /*** SET BUTTONS' FILENAMES HERE ***/. This creates a
    mouseover when the drop down is activated. Put all your onmouseover images under: oversources = new
    array; and your onmouseout images under : upsources. Be sure to set your on and out images above
    each other. CODE /*** SET BUTTON'S FOLDER HERE ***/ var buttonFold....
  30. Java editor
    (72)
    In your opinion what's the best java editor/compiler? i use jcreator le and it works nicely.......

    1. Looking for create, java, button, frame, customized

Searching Video's for create, java, button, frame, customized
advertisement



How To Create Java Button Or Frame - to be customized



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE