fileMenu.setMnemonic(KeyEvent.VK_F); // Alt + f for file editMenu.setMnemonic(KeyEvent.VK_E); // Alt + e for edit helpMenu.setMnemonic(KeyEvent.VK_H); // Alt + h for help loadItem.setMnemonic(KeyEvent.VK_L); // l for load saveItem.setMnemonic(KeyEvent.VK_S); // s for save exitItem.setMnemonic(KeyEvent.VK_E); // e for exit
Awesome tutorial man! Unfortunately when I went by your idea of implementing the listen, just in an inner class, the listener didn't respond to the events at all :( , ended up making individual listeners for each of the fields of my class, wich solved the problem 👍
Thanks for the tut, this'll save me a lot of bother! Question - do you create your own icons or find/buy them? I'm having trouble finding uniform-style icon sets so I've started to build my own.
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
Why are you not making videos about other languages, for example why are you no longer making videos about C#? (I'm sorry if you've already said why, i started watching your C# series a couple of days ago). Btw your tutorials are very helpful and fun to watch, thank you for making them :)
Hey, Bro! I hope you will read this but my icons were always big. I'm using eclipse 2023 and also the sysout ctrl + space shortcut can only use 1 time. Please help me
On a Mac these don't do anything :( : fileMenu.setMnemonic(KeyEvent.VK_F);//Alt + f for file editMenu.setMnemonic(KeyEvent.VK_E);//Alt + e for edit helpMenu.setMnemonic(KeyEvent.VK_H);//Alt + h for help
its ctrl + option on a Mac. just spent ages working it out! can't get the load/save/exit item to work though, it selects them in the menu but doesn't execute the actions. so exit doesn't actually exit when i press e! just highlights it in the menu
public class Main{
public static void main(String[] args) {
new MyFrame();
}
}
import java.awt.FlowLayout;
import java.awt.event.*;
import javax.swing.*;
public class MyFrame extends JFrame implements ActionListener{
JMenuBar menuBar;
JMenu fileMenu;
JMenu editMenu;
JMenu helpMenu;
JMenuItem loadItem;
JMenuItem saveItem;
JMenuItem exitItem;
//ImageIcon loadIcon;
//ImageIcon saveIcon;
//ImageIcon exitIcon;
MyFrame(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(100,100);
this.setLayout(new FlowLayout());
//loadIcon = new ImageIcon("load.png");
//saveIcon = new ImageIcon("save.png");
//exitIcon = new ImageIcon("exit.png");
menuBar = new JMenuBar();
fileMenu = new JMenu("File");
editMenu = new JMenu("Edit");
helpMenu = new JMenu("Help");
loadItem = new JMenuItem("Load");
saveItem = new JMenuItem("Save");
exitItem = new JMenuItem("Exit");
loadItem.addActionListener(this);
saveItem.addActionListener(this);
exitItem.addActionListener(this);
//loadItem.setIcon(loadIcon);
//saveItem.setIcon(saveIcon);
//exitItem.setIcon(exitIcon);
fileMenu.setMnemonic(KeyEvent.VK_F); // Alt + f for file
editMenu.setMnemonic(KeyEvent.VK_E); // Alt + e for edit
helpMenu.setMnemonic(KeyEvent.VK_H); // Alt + h for help
loadItem.setMnemonic(KeyEvent.VK_L); // l for load
saveItem.setMnemonic(KeyEvent.VK_S); // s for save
exitItem.setMnemonic(KeyEvent.VK_E); // e for exit
fileMenu.add(loadItem);
fileMenu.add(saveItem);
fileMenu.add(exitItem);
menuBar.add(fileMenu);
menuBar.add(editMenu);
menuBar.add(helpMenu);
this.setJMenuBar(menuBar);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==loadItem) {
System.out.println("*beep boop* you loaded a file");
}
if(e.getSource()==saveItem) {
System.out.println("*beep boop* you saved a file");
}
if(e.getSource()==exitItem) {
System.exit(0);
}
}
}
You are the best. Thanks for lessons
I thoroughly enjoyed your Java tutorial playlist.
Awesome tutorial man! Unfortunately when I went by your idea of implementing the listen, just in an inner class, the listener didn't respond to the events at all :( , ended up making individual listeners for each of the fields of my class, wich solved the problem 👍
Muito bom que legal parece fácil vc fazendo
Top muito bom mesmo 👏👏👏👏👏
Thanks for the awesome video
Thank you teacher for this video
Thanks for the tut, this'll save me a lot of bother!
Question - do you create your own icons or find/buy them? I'm having trouble finding uniform-style icon sets so I've started to build my own.
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
Love the content Bro
thanks for watching!
Thanks for your wisdom bro
Good tutorial
You're awesome dude, thank you so much
really nice
Why are you not making videos about other languages, for example why are you no longer making videos about C#? (I'm sorry if you've already said why, i started watching your C# series a couple of days ago). Btw your tutorials are very helpful and fun to watch, thank you for making them :)
@@aproe610 I know, my first language was java, but recently i started learning C# because I wanna get into game development
I lost motivation since that playlist wasn't receiving many views. Although I do have plans to go back and finish that playlist
your videos have been a lot of help bro, thanks bro
I like when you say.. hii whats up guys its bro here😀
u are super hero man
When doing this I get arrows for my drop downs that point right, I am not sure what I did wrong.
Grazie per il tuo lavoro
Nice video
How we can change the Icon`s size?
thank you for the content
Hello,,,may we please have the link where you are downloading your imageicons from
Hey, Bro! I hope you will read this but my icons were always big. I'm using eclipse 2023 and also the sysout ctrl + space shortcut can only use 1 time. Please help me
Menu Listener how to function?
thanks bro
❤❤
Thanks
Much respect ()
Grand!
Make c# toturial plz. But not for beginners it must be in intermediate level
I will at some point, shouldn't take too long until then
Thanks!
Thx for help.
thanks for watching!
👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍
*dropping comment below*
drunkenn menu
thank you
For the algorithm
:)))))))))
comment
On a Mac these don't do anything :( :
fileMenu.setMnemonic(KeyEvent.VK_F);//Alt + f for file
editMenu.setMnemonic(KeyEvent.VK_E);//Alt + e for edit
helpMenu.setMnemonic(KeyEvent.VK_H);//Alt + h for help
its ctrl + option on a Mac. just spent ages working it out! can't get the load/save/exit item to work though, it selects them in the menu but doesn't execute the actions. so exit doesn't actually exit when i press e! just highlights it in the menu
Thanks