| | 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!!! thank!!!! |
| Nov 21, 2009 |
buttons with same name How To Create Java Button Or Frame good evening. if we have 2 buttons with the same name and each button related to an event how could the system distinguish between them if we select one? thanks -reply by rasha
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!!! 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
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.
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);
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"));
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(); 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" ? 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. 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
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(); } } Latest Entries
buttons with same name
How To Create Java Button Or Frame good evening. if we have 2 buttons with the same name and each button related to an event how could the system distinguish between them if we select one? thanks -reply by rashaYes 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" ? overwrite the "paint(graphics g)" method public class CustomeButton extends JButton{ public CustomeButton(){ setBorderPainted(false); setContentFilled(false); } public void paintComponent(Graphics g){ g.SetColor(Color.White); g.FillRoundRect(0,0,100,30,5,5); } }//end class
you can extend more features to this class and create more graphical button baii -reply by hacker
displaying a messagebox
How To Create Java Button Or Frame Replying to iGuest You can use JOptionPane.ShowMessageDialog(null,"YOUR MESSAGE HERe!!","NAME OF TITLE BAR HERE!!",JOptionPane.PLAIN_MESSAGE);//you can use JOptionPane.INFORMATION_MESSAGE if you want an information icon,JOptionPane.ERROR_MESSAGE if you want an error icon,JOptionPane.WARNING_MESSAGE if you want a warning icon, JOptionPane.QUESTION_MESSAGE if you want to pose a question to he user -reply by joseph
what with all customize?
How To Create Java Button Or Frame How can I make my own customized button and put it in my program (JAVA) Let's say I have predone program with a button and I have done my one button picture in Photoshop (and let's say it's form is a circle) How can I change the regular look of a windows button or java button to this my own. What code do I need? -reply by solomon
Similar Topics
Keywords : create, java, button, frame, customized
Does any one know about this ? (8) Hello friends , just now i came accross a particular type of script which is capable of masking the which is good (13) Hi, I want to know which is going to be a success in future. I've asked this question to (1) XML and JavaGeneral XML resources * "XML, Java and the Future of the Web," Jon Bosak. The (2) So we have a web based application running on JBoss on several clustered servers. The front end of (5) See the next few lines containing Java Code: CODE 1. // imports 2. import (0) How can i call pdf995 engine from Java to generate Pdf from Doc. This approach from Visual Basic (2) Hi, I'm interested in game creation on websites. The game should be playable via web browser. (1) I had found this site >> http://learnjava.awardspace.com This website is for people who want (19) Many having tell me to make my MMORPG in java leads me to agree, But I'm not sure truly is it (2) Hey there, I have made an applet that shows images moving about the screen. I have pause/resume I need help with a method using iterator (3) /** * Remove from the club's collection all members who * joined in the given month, Command Prompt on right click menu (3) With this registry edit you can easily open the current folder in prompt without going through any (5) so most of you guys know mig33. its a wap application,probaly java.most kindly to be java. does Your Opinion About The Best Java Framework (11) What is the best framework to make enterprise application using Java (J2EE)? Currently I am are they the same or different (7) I think most of you always confuse about java and javascript .So I make this topic to talk about it. All your queries regarding Java Programming goes here. (10) Hellow friends, I am creating this thread for all queries and suggestions related to java coding. If (6) (A splash screen is an image that pops up before you run a program, sometimes it tells you what (7) aving some problems taking in the Java at Uni, Was wondering if anyone could shine some light on it (3) I think I have nearly managed to create a JNLP file and get my application running successfully. File Upload Script in JAVA (5) Hi, I am developing my personal website in JSP. I need a file upload script written in JAVA. I got a What you wanna have on your phone ? (9) I'm trying to do a Java mobile J2me application... But I don't know what to do... Any Works with Firefox, not IE (10) CODE var popUpWin=0; function popUpWindow(URLStr) { if(popUpWin) { (11) Does anyone knows a good tutorial or book to learn Java?. I need to learn it quickly for a course in By The Book (5) I travel alot so I get a chance to catch up on my reading. I bought a book today about javascripts. (2) Java, developed under the Sun Microsystems brand, is a full-fledged object-oriented programming Run Java program on double click (11) Some of the installables in java comes in form of .jar file, one has to just double click or type no need to download the sun java SDK =) (6) Hey everyone, I found a site with a free online java compiler where you choose a source .java file (6) this is the best websites for javascript and other javascript.internet.com javascriptkit.com (75) In your opinion what's the best java editor/compiler? i use jcreator le and it works nicely....... Looking for create, java, button, frame, customized
|
![]() How To Create Java Button Or Frame - to be customized |
Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com