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.
|
// Apply hover functionality to all buttons, as well as removing certain default stylings.
|
||||||
private void applyCommon() {
|
private void applyCommon() {
|
||||||
addMouseListener(
|
// TODO: Implement hover functionality.
|
||||||
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();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setFocusPainted(false);
|
setFocusPainted(false);
|
||||||
setBorder(new EmptyBorder(3,3,3,3));
|
setBorder(new EmptyBorder(3,3,3,3));
|
||||||
|
|
||||||
repaint();
|
|
||||||
revalidate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-19
@@ -15,24 +15,6 @@ public class Panel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
setBackground(bg);
|
// TODO: Add 2 buttons to the Panel object, and set the background and foreground colors.
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user