#How do I do this action listener?
1 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @copper mantle! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
// Button 1
button.setText("User " + name + "'s journal! 🌼");
button.setFocusable(false);
button.setForeground(new Color(0, 0, 0));
button.setBackground(new Color(255, 252, 253));
button.setHorizontalTextPosition(JButton.CENTER);
button.setVerticalTextPosition(JButton.BOTTOM);
button.setIconTextGap(-15);
button.setBorder(BorderFactory.createEtchedBorder());
button.setEnabled(true);
button.setLayout(new BorderLayout(100,100));
button.setPreferredSize(new Dimension(10,60)); //width, height
public void actionPerformed(ActionEvent e) {
if(e.getSource() == button);
}
}
Hi @copper mantle, I’m Alexander Lill (a real person), a researcher at the University of Zurich. I’m trying to help people receive answers faster on Discord. If you are not ok with me trying to help you, click the 🚪 symbol, and I will delete this message and apologize for the inconvenience.
Based on your question, I suggest the following links. Please click the number-emoji for each link that was helpful for you, and on the ❌ if none of the links was helpful for you.
1️⃣ Code - ChangeListener - ChangeListener - ChangeListener
<#help-americano message>
2️⃣ Help With Your Code!
<#help-marocchino message>
3️⃣ Actionlistener Implementation
<#help-espresso message>
Let me know if you have any questions! More info: #announcements message
Make an actionlistener implementation and pass it to all buttons
public class MyListener implements ActionListener {
...
}
Then
JButton btn1 = ...
JButton btn2 = ...
MyListener x = new MyListener();
btn1.addActionListener(x);
btn2.addActionListener(x);
You can also do this in the same class as a lambda but we won't go there
Thank you so much!
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
Thank you for your feedback imp_o_rt, appreciate it 🙂
I’d like to invite you and @copper mantle to fill in a short follow-up survey on your experience with the suggested links and your feedback (max. 10 mins).
We would highly appreciate your feedback to help our research project. For your efforts, you can decide to be entered in a raffle for an Amazon gift card of USD 100 value (voluntary).
To participate in the survey, please answer the questions in the following link. Your responses will be treated confidentially.
https://uzhwwf.qualtrics.com/jfe/form/SV_1zWdrjjRfwFGXwa?ST=DI&CO=JC&CI=7399003
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
Dear @copper mantle, just in case you forgot and are interested, I would be thankful if you could fill out my survey. If not, I apologize for the @ mention. This will be my last message 🙂