i'm new to JAVA and i need to know how can i design my jframe like this.this look is when i creating my java project
and this look is after run the programe,
how can i create my java jframe looks like flat look,like this ...
how you are increase your java application more beautiful :)
There is a few things to do to get your frame looking as close as possible to the show one, ill bullet point each step and post examples below
First for the color background, you are going to need to do this for the outside panel (the one holding the login label and the username/password panel) and then also the username/password panel.
Second you are going to need to add borders to both panels, for the first one you are just going to need to add a simple line border and set the color to white. For the second inner panel, it looks like you already have an etched border but you want to change that to createTitleBorder where you can state the border you wish to choose and the title which will be "Login"
Next you are going to want to set the text to white, do this by changing your JLabels text to white using JLabel.setForegroundColor.
Lastly you want to change the textbox background color to dark blue using JTextField.setBackground(//blue color).
Code Example
//BackgroundColor
myLabel.setBackgroundColor(//your color);
//Border one
myPanel.setBorder(BorderFactory.createLineBorder(Color.White));
//Border two
myPanel.setBorder(BorderFactory.createTitleBorder(//your border choice, "Login");
//Set text color
myLabel.setForegroundColor(Color.White);
//Change textbox background color
myTextBox.setBackground(//blueColor);
Hope this helps, if you have an issues just ask.
Related
I'm Facing a problem while I try to add a label on the face of just another label in Java Netbeans. Every time I add a label just above of another label the new label (say label2) automatically goes to the leftmost side and shrink my first label( say label1). Actually, I want to add a background color blue to the top of the form as there are no other possible ways (as I know) to change certain parts of the form to another color I use this way. If there is another way of changing the background of certain parts of a form, share with me. But also help to add a label just above another label.
Thanks in advance .. :)
The following Image will show you my intention. Notice only to the head. There is a label on the left side of a blue label. I want to add that label on the surface of the blue label.
This is the image of Interface which I want to gain in JAVA. This is a Visual Basic MDI Form and list of options are available on the rightmost side. That's what I try to do but couldn't do yet.
Because it wont let me add an image - new account
This is utilizing the Java GUI
The above image is an image pasted onto a button, I've tried to make the button transparent so that the user can't see it but I can't seem to get rid of this blue border.
Code I have so far
boss2 = new JButton(); //declared the static button earlier on in the code
boss2.setSize(300, 300);
boss2.setLocation(315, 200);
boss2.setIcon(new ImageIcon("dragon.gif"));
boss2.setRolloverIcon(new ImageIcon("dragon.gif"));
boss2.setOpaque(false);
boss2.setContentAreaFilled(false);
boss2.setBorder(null);
Is there a way to get rid of the blue border surrounding my image?
edit - sorry for the earlier mishap, uploaded the wrong file
I would suggest that what you are seeing is the focus rectangle, used to "highlight" the button as having keyboard focus.
You can use boss2.setFocusPainted(false); to stop it from been painted.
To not have a boarder drawn for a JButton (assuming that you are using javax.swing.JButton) you can simply do:
boss2.setBorderPainted(false);
I currently have a JDialog (class that implements JDialog and is constructed like a jframe), and has 3 swing buttons placed on it. Currently I have it set, undecorated = true, to hide the outer frame. Is there any way to use my image to replace the default square frame?
This is what I aim for :
The blue square with shadow is the pre made image.
Regards
The blue square with shadow is the pre made image.
Well, the best way would be to set the background of the panel and then add a ShadowBorder to the panel. This will provide you with far more flexibility in the future as you can create many panels with different colors and reuse the same ShadowBorder instead of having to create an Image every time. I don't have an example of a ShadowBorder, but you might find one if you search the web.
Is there any way to use my image to replace the default square frame?
But if you really want to use your premade Image, then you can just:
create a JLabel and add your Image to the label as an Icon
add the label to the dialog
set the layout manager of the label
add your components to the label.
I want to make an account screen for a project, but I'm still new to GUI's. This is my first time working with a JComboBox and I'm having a bit of trouble. I want to basically place the JComboBox inside a box, which will be part of my background image. I tried using BorderLayout, but that just made a giant combobox that took up my entire screen. I have my code here and a drawing which illustrates my goal below:
See this answer for 2 layouts that can easily center the panel containing the combo box.
Use borders and layout padding within that panel for the white space required.
I have 3 image so I want, if I drag any image that should appear above all the other images. Which technique can use? please any idea???? By the way I am using "ImageIcon".
Thanks in advance.
If what you want to do is click on an image, lift it above the others and then drag it, consider placing them in ImageIcons and these in JLabels, and displaying them in a JLayeredPane, or a JPanel that is held in a JLayeredPane. You can then lift the clicked label onto the JLayeredPane.DRAG_LAYER while dragging, and then drop it down into the DEFAULT_LAYER (or on a JPanel that's on the DEFAULT_LAYER) when done. For an example of this, please see my code in a related question: dragging a jlabel around the screen
If I'm totally off base, sorry, but please correct my incorrect assumptions.
By the way I am using "ImageIcon".
I assume this means you are adding in image to a JLabel and are then adding the JLabel to a JPanel.
so I want, if I drag any image that should appear above all the other images
You need to add a MouseListener to the JLabel. When you click on the label then you can reset its Z-Order to 0. This will cause the label to be painted last and so it will be on top of all other labels on the panel.
So the basic code in the MouseListener would be:
panel.setComponentZOrder(label, 0);