challenge code
This commit is contained in:
+1
-28
@@ -40,36 +40,9 @@ public class Button extends JButton {
|
||||
|
||||
// Apply hover functionality to all buttons, as well as removing certain default stylings.
|
||||
private void applyCommon() {
|
||||
addMouseListener(
|
||||
new MouseListener() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
select();
|
||||
repaint();
|
||||
revalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
deselect();
|
||||
repaint();
|
||||
revalidate();
|
||||
}
|
||||
});
|
||||
// TODO: Implement hover functionality.
|
||||
|
||||
setFocusPainted(false);
|
||||
setBorder(new EmptyBorder(3,3,3,3));
|
||||
|
||||
repaint();
|
||||
revalidate();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-19
@@ -15,24 +15,6 @@ public class Panel extends JPanel {
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setBackground(bg);
|
||||
setForeground(fg);
|
||||
|
||||
Button b = new Button("Example text", new Color(160, 32, 240), Color.WHITE);
|
||||
b.addActionListener(
|
||||
e -> {
|
||||
System.out.println("Button action.");
|
||||
}
|
||||
);
|
||||
|
||||
Button b2 = new Button("Example 2 text", new Color(160, 32, 240), Color.WHITE);
|
||||
b2.addActionListener(
|
||||
e -> {
|
||||
System.out.println("Button 2 action.");
|
||||
}
|
||||
);
|
||||
|
||||
add(b);
|
||||
add(b2);
|
||||
// TODO: Add 2 buttons to the Panel object, and set the background and foreground colors.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user