From 1704a22847ee8cf497a5492f9d0a60def31651fb Mon Sep 17 00:00:00 2001 From: Snowyfox Date: Sat, 31 Jul 2021 07:36:56 -0400 Subject: [PATCH] Prepared functional hooks in PostWindow --- PostWindow.java | 90 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 7 deletions(-) diff --git a/PostWindow.java b/PostWindow.java index ff210ac..706c14c 100644 --- a/PostWindow.java +++ b/PostWindow.java @@ -83,6 +83,36 @@ implements ActionListener { repliesDisplay.setReplies(replies); } + public void + openAuthorProfile() + { + + } + + public void + favourite() + { + + } + + public void + boost() + { + + } + + public void + reply() + { + + } + + public void + openMedia() + { + + } + // - -%- - public void @@ -119,7 +149,7 @@ implements ActionListener { setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLocationByPlatform(true); - postDisplay = new PostComponent(); + postDisplay = new PostComponent(this); repliesDisplay = new RepliesComponent(); @@ -152,7 +182,11 @@ implements ActionListener { class -PostComponent extends JPanel { +PostComponent extends JPanel +implements ActionListener { + + private PostWindow + primaire; private String author, time, text; @@ -163,7 +197,7 @@ PostComponent extends JPanel { profile, favouriteBoost, replyMisc, - prevNext, + nextPrev, media; // ---%-@-%--- @@ -191,6 +225,41 @@ PostComponent extends JPanel { // - -%- - + public void + actionPerformed(ActionEvent eA) + { + Object src = eA.getSource(); + + /* + * Umm, ActionEvent is the wrong thing to listen for here. + * We want mouse presses. The custom button would publish + * events that mention which button it was. + * + * Default JButton ignores RMB. + */ + + if (src == profile) + { + primaire.openAuthorProfile(); + } + else if (src == favouriteBoost) + { + // Fancy!! + } + else if (src == replyMisc) + { + + } + else if (src == nextPrev) + { + + } + else if (src == media) + { + primaire.openMedia(); + } + } + protected void paintComponent(Graphics g) { @@ -230,32 +299,39 @@ PostComponent extends JPanel { // ---%-@-%--- - PostComponent() + PostComponent(PostWindow primaire) { + this.primaire = primaire; + author = time = text = ""; profile = new JButton("P"); profile.setSize(40, 40); + profile.addActionListener(this); favouriteBoost = new JButton("☆/B"); favouriteBoost.setSize(40, 40); + favouriteBoost.addActionListener(this); // We have to overload the buttons to accept RMBs. // Which perform the secondary functionality. replyMisc = new JButton("R"); replyMisc.setSize(40, 40); + replyMisc.addActionListener(this); - prevNext = new JButton("↓/↑"); - prevNext.setSize(40, 40); + nextPrev = new JButton("↓/↑"); + nextPrev.setSize(40, 40); + nextPrev.addActionListener(this); media = new JButton("M"); media.setSize(40, 40); + media.addActionListener(this); setLayout(null); profile.setLocation(8, 8); add(profile); favouriteBoost.setLocation(8, 8+48); add(favouriteBoost); replyMisc.setLocation(8, 8+48+48); add(replyMisc); - prevNext.setLocation(8, 8+48+48+48); add(prevNext); + nextPrev.setLocation(8, 8+48+48+48); add(nextPrev); media.setLocation(8, 8+48+48+48+48); add(media); /*