Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
One of the options
public class Enter {
public static void main(String... args){
new ColorLayout();
}
}
import java.awt.*;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public class ColorLayout extends JFrame{
public ColorLayout() {
this.add(new ColorPanel());
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(new Dimension(200,200));
this.setVisible(true);
}
public class ColorPanel extends JPanel{
private JButton button;
private JPanel buttonpanel;
public ColorPanel() {
buttonpanel = new JPanel();
buttonpanel.setBackground(Color.decode("#eeeeee"));
button = new JButton("Жми, чтобы узнать цвет");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
System.out.println(buttonpanel.getBackground());
}
});
buttonpanel.add(button);
this.add(buttonpanel);
}
}
}
To get the color of the layout set for the current activity, do:
View v = new View(this);
v.getSolidColor();
And by default, the background corresponds to the standard theme, which is written in the manifest.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question