Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package util;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.UUID;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JTextArea;
- import javax.swing.SwingUtilities;
- import org.pushingpixels.trident.Timeline;
- import org.pushingpixels.trident.ease.Spline;
- public class ButtonFg extends JFrame {
- public ButtonFg() {
- JButton button = new JButton("sample");
- button.setForeground(Color.blue);
- // this.setLayout(new FlowLayout());
- // this.add(button);
- JPanel panel = new JPanel(new BorderLayout());
- // panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
- this.add(panel);
- String s = UUID.randomUUID().toString();
- for (int i = 0; i < 20; i++) {
- s += "\n" + UUID.randomUUID().toString();
- }
- final JTextArea textArea = new JTextArea(s);
- textArea.setLineWrap(true);
- final JScrollPane jsp = new JScrollPane(textArea);
- jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- final JButton label = new JButton("Show details...");
- panel.add(label, BorderLayout.NORTH);
- panel.add(jsp, BorderLayout.CENTER);
- panel.add(new JLabel("End of panel"), BorderLayout.SOUTH);
- final Timeline rolloverTimeline = new Timeline(jsp);
- rolloverTimeline.addPropertyToInterpolate("size", new Dimension(400, 15), new Dimension(400, 200));
- rolloverTimeline.setEase(new Spline(0.8f));
- rolloverTimeline.setDuration(300);
- rolloverTimeline.setInitialDelay(50);
- label.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (label.getText().toLowerCase().contains("show")) {
- rolloverTimeline.play();
- label.setText("Hide details...");
- } else {
- rolloverTimeline.playReverse();
- label.setText("Show details...");
- }
- }
- });
- rolloverTimeline.playReverse();
- this.setSize(400, 500);
- this.setLocationRelativeTo(null);
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- new ButtonFg().setVisible(true);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement