Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i = 65; i < 91; i++){
- alphabetPanel.add(new JButton("<html><center>" + (char)i));
- }
- ActionListener listener = something;
- for (int i = 65; i < 91; i++){
- JButton button = new JButton("<html><center>" + (char)i);
- button.addActionListener( listener );
- alphabetPanel.add(button);
- }
- for (int i = 65; i < 91; i++){
- JButton button = new JButton("<html><center>" + (char)i));
- button.addActionListener( new ButtonListener());
- alphabetPanel.add(button);
- }
- class ButtonListener implements ActionListener {
- ButtonListener() {
- }
- public void actionPerformed(ActionEvent e) {
- //TODO:
- }
- }
- button.setName((char)i)); // or button.setName(i);
- alphabetPanel.add(new JButton("<html><center>" + (char)i) {{
- addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- ...
- }
- });
- }});
- alphabetPanel.add(new JButton(new AbstractAction("<html><center>" + (char)i) {
- public void actionPerformed(ActionEvent event) {
- ...
- }
- }));
- Form alphabetForm = new Form(alphabetPanel);
- for (char c='A'; c <= 'Z'; ++c) {
- alphabetForm.button("<html><center>" + c, new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- ...
- }
- });
- }
- new JButton().addActionListener(new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent arg0) {
- // TODO your action
- }
- });
- for (int i = 65; i < 91; i++){
- alphabetPanel.add(new JButton("<html><center>" + (char)i).addActionListener(new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent arg0) {
- // TODO your action
- }
- }));
- }
Add Comment
Please, Sign In to add comment