import java.awt.*;
import de.javasoft.plaf.synthetica.SyntheticaClassyLookAndFeel;
import javax.swing.*;
public class TB extends JFrame
{
{
try
{
UIManager.setLookAndFeel(new SyntheticaClassyLookAndFeel());
}
catch (Exception e)
{
e.printStackTrace();
}}
TB() throws ClassNotFoundException
{
frame1();
}
public void frame1()
{
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
p.setBackground(new Color(0,0,0,100));
JPanel p1 = new JPanel();
p1.setBackground(new Color(0,0,0,100));
JLabel jl = new JLabel("");
setContentPane(new JLabel(new ImageIcon("src\\ New folder\\1.jpg")));
p1.add(jl);
p1.setVisible(true);
p1.setSize(200,150);
add(p1);
JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout());
p2.setSize(200,100);
p2.setBackground(new Color(0,0,0,125));
JButton hm = new JButton ("Home");
JButton abt = new JButton("AboutUs");
JButton log = new JButton("SignIn");
p2.add(hm);
p2.add(abt);
p2.add(log);
add(p2);
add(p);
JPanel p3 = new JPanel();
p3.setLayout(new GridLayout(3,1,0,0));
p3.setBackground(new Color(0,0,0,100));
JLabel usr = new JLabel("Username :");
usr.setForeground(Color.white);
JTextField usrtxt = new JTextField();
Component pass = new JLabel("Password :");
pass.setForeground(Color.white);
JPasswordField passtxt = new JPasswordField(20);
JButton login = new JButton("Login");
JButton cancel = new JButton("Clear");
p3.add(usr);
p3.add(usrtxt);
p3.add(pass);
p3.add(passtxt);
p3.add(login);
p3.add(cancel);
p.add(p3);
p3.setVisible(false);
setTitle(" Generator 1.0");
setLayout(new GridLayout(3,1,0,0));
setSize(1364,700);
setVisible(true);
JPanel p4 = new JPanel();
p4.setBackground(new Color(0,0,0,100));
JLabel msg = new JLabel("About Us",JLabel.CENTER);
msg.setForeground(Color.white);
p4.setLayout(new GridLayout(5,1));
p4.add(msg,JLabel.CENTER_ALIGNMENT);
p.add(p4);
p4.setVisible(false);
}
public static void main(String[]args) throws ClassNotFoundException
{
TB TTV = new TB( );
new TB();
TTV.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
This new Color(0,0,0,100)
isn't how you to transparency in Swing. Swing only deals with fully transparent or opaque components. In this case, specifying a alpha based color, the painting process doesn't know that it should be painting beneath the component, leading to all sorts of weird painting atrificates.
If you want transparency, then you need to fake it, but making the component completely transparent (setOpaque(false)
) and overriding the component's paintComponent
method and filling the component area with the translucent color you want