Is there any way to alter the looks of specific java components? Say I want to remove the borders around a JTextField, for example.
I've searched the internet for answers with no result, but I'm sure you can help me. Thanks!
Java graphical component looks
Started by oskargustafsson, Aug 10 2006 04:31 PM
3 replies to this topic
#1
Posted 10 August 2006 - 04:31 PM
#2
Posted 29 August 2006 - 11:04 PM
maybe just draw a box around the border of the textfield matching the BG colors, if your BG is multicolored well then i dont know, im a noob
no img code allowed huh?
#3
Posted 30 August 2006 - 07:56 AM
Yes there are ways to alter the default look for a Swing component. For your specific example look up setBorder method in JComponent (JtextField inherits from JComponent).
Use the documentation!
WildChild
Use the documentation!
WildChild
#4
Posted 30 August 2006 - 10:07 PM
Yes, look into the javax.swing.plaf.synth package.
Another option is to create a custom class that inherits the component and you do the custom painting in the paintComponent method, like this:
- dega
Another option is to create a custom class that inherits the component and you do the custom painting in the paintComponent method, like this:
import java.awt.*;
import javax.swing.*;
public class MyComponent extends JComponent // replace with the component you wish to alter
{
// ... constructor etc..
protected void paintComponent(Graphics g)
{
super.paintComponent(g); // make the component paint itself
// do all of your custom painting here...
}
}
- dega
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











