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
I am developing an android Filemanager app. I used checkbox to select files and folders(files+subfolders) . I want to add feature to copy paste the selected files and folders(files+subfolders) at same time like google Filemanager . How can i add this copy paste feature in my java android file manager??? Advance Thanks..
im assuming u asked this cz u did that in the main method in that case, you need to construct an object of your class (idk how to say it sry my eng isnt good) Here is my code, i hope u will get it import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; public class abc implements ActionListener { public static void main(String[] args) { JFrame frame = new JFrame("Title"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(420,420); frame.setLayout(null); //Creating the Button JButton button = new JButton("I am a button :D"); button.setBounds(0, 0, 150,69); //creating an object of the class (idk how to say it lol sry but im sure yk of it) abc abcObject = new abc(); //Using the object instead of this keyword button.addActionListener(abcObject);
//There is also another way, i guess its called lambda expression //This has no relation to the previous button we created earlier JButton button2 = new JButton("2nd button"); button2.setBounds(69,69,100,69); button2.addActionListener(e -> System.out.println("This action was performed using lambda expression"));
//adding button and making frame visible frame.add(button); frame.add(button2); frame.setVisible(true);
} @Override public void actionPerformed(ActionEvent e) {
but i would recommend u doing the way he did in the tutorial. I think its simpler there are probably more ways to do it, this one is simplest, u just have to use 'this' and its done
Hey hope you are doing alright just I wanna say that GOD loved the world so much he sent his only begotten son Jesus to die a brutal death for us so that we can have eternal life and we can all accept this amazing gift this by simply trusting in Jesus, confessing that GOD raised him from the dead, turning away from your sins and forming a relationship with GOD.
public class Main{
public static void main(String[] args) {
// JFileChooser = A GUI mechanism that let's a user choose a file (helpful for opening or saving files)
new MyFrame();
}
}
import java.awt.FlowLayout;
import java.awt.event.*;
import java.io.File;
import javax.swing.*;
public class MyFrame extends JFrame implements ActionListener{
JButton button;
MyFrame(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
button = new JButton("Select File");
button.addActionListener(this);
this.add(button);
this.pack();
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==button) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(new File(".")); //sets current directory
int response = fileChooser.showOpenDialog(null); //select file to open
//int response = fileChooser.showSaveDialog(null); //select file to save
if(response == JFileChooser.APPROVE_OPTION) {
File file = new File(fileChooser.getSelectedFile().getAbsolutePath());
System.out.println(file);
}
}
}
}
Practicing...
public class Main{
public static void main(String[]args){
new MyFrame();
}
}
*****************************
import java.awt.FlowLayout;
import java.awt.event.*;
import java.io.File;
import javax.swing.*;
public class MyFrame extends JFrame implements ActionListener{
JButton button;
MyFrame(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
button = new JButton("Choose a file");
button.addActionListener(this);
this.add(button);
this.pack();
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e){
if(e.getSource()==button){
JFileChooser fileChooser = new JFileChooser();
// fileChooser.setCurrentDirectory(new File(""));
fileChooser.setCurrentDirectory(new File("C:\\Users\\Yaa\\Desktop"));
//System.out.println(fileChooser.showOpenDialog(null));
//int response = fileChooser.showOpenDialog(null);
int response = fileChooser.showSaveDialog(null);
if(response ==JFileChooser.APPROVE_OPTION){
File file = new File(fileChooser.getSelectedFile().getAbsolutePath());
System.out.println(file);
}
}
}
}
this channel has single handedly gotten me through all my JavaFX learning. Insane value.
bro this channel is so awesome. You have the most helpful vids, get straight to the point, and explain everything well. 10/10 major props to you
thanks for watching Alex
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 your content, keep up the good work! Really appreciate your tutorials. You have helped me out countless of times!
Big ups BroCodez u dun know, i was bare scared my code aint gon work but you solved it u mad lad!
Excellent content
Great vid! Please could you link me to the videos you have on saving and opening the files?
it's a really helpful tutorial, thanks
4:26 "Nuclear launch codes" xD
Good tutorial
Nice video
Keep it up bro
You're the best teacher.
Thank you very much bro❤ you helped us a lot🎉
Thanks for your great work! Please, maybe more explanation for each assignment.
thank you bro keep forward
Thanks for the video mate, you're a real help
nice
Thanks. Your video helped me a lot.
Help ful
hi bro, i so love your video man!!! keep going like this!!🤟🤟🤟
Great video!
Is their a way to print it on a JTextArea when you open a file?
Very helpful :) thanks bro
good job Bro
I am developing an android Filemanager app. I used checkbox to select files and folders(files+subfolders) . I want to add feature to copy paste the selected files and folders(files+subfolders) at same time like google Filemanager . How can i add this copy paste feature in my java android file manager??? Advance Thanks..
Love you bro! Thanks a lot for your vids, very helpful ! Comment done ehehehe enjoy and keep up! Best regards
how can you set this to open on action in a gui, for example i press a load file button and this comes up to choose a file etc...
nice video, thanks.
Thanks dude that helps a lot
thanks that helped me
Instead of printing the path I want to store it in a String to use for another function, how can I get a from this function?
You are my Hero Bro.!
Bro, 👍👌
Excellent!
thank you for the content
Thank you brother. You earned a subscription from me.
Thanks, Brah!
perfect
8:34 Nuclear launch codes! :3
Is there a way to make a drag/drop interface for files?
Thanks from Brazil , how to save image path in mysql database
Very helpful.
bro, you're the best
Thank you so mutch!!!!!!
thanks bro
could you add the implementation of DnD facilities for this button?
super
Hi, I've been wondering, instead of "this", what else that I can put in the addActionListener(this) that will match the parameter?
You can given parent component where you implement ActionListener . actually he using same class that why he use (this)
I hope you understand
im assuming u asked this cz u did that in the main method
in that case,
you need to construct an object of your class (idk how to say it sry my eng isnt good)
Here is my code, i hope u will get it
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class abc implements ActionListener {
public static void main(String[] args) {
JFrame frame = new JFrame("Title");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(420,420);
frame.setLayout(null);
//Creating the Button
JButton button = new JButton("I am a button :D");
button.setBounds(0, 0, 150,69);
//creating an object of the class (idk how to say it lol sry but im sure yk of it)
abc abcObject = new abc();
//Using the object instead of this keyword
button.addActionListener(abcObject);
//There is also another way, i guess its called lambda expression
//This has no relation to the previous button we created earlier
JButton button2 = new JButton("2nd button");
button2.setBounds(69,69,100,69);
button2.addActionListener(e -> System.out.println("This action was performed using lambda expression"));
//adding button and making frame visible
frame.add(button);
frame.add(button2);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("69420 ");
}
}
but i would recommend u doing the way he did in the tutorial. I think its simpler
there are probably more ways to do it, this one is simplest, u just have to use 'this' and its done
Awesome, bro :)
I have a question, how can I copy the selected file?
thnx dude, helped a lot
Amazing!! :D
Thanks bro.
Thanks!
thanks! it's what i need...
Pls how to u add file to read in Jframe ?
Need help.
Perfecto
thank you so much
thanks man
my uni project: stonks
عاشت ايدك
thank you
thanks
A comment down below
hello
file selects you
bow down in front of bro
Hey hope you are doing alright just I wanna say that
GOD loved the world so much he sent his only begotten
son Jesus to die a brutal death for us so that we can have eternal life and we can all accept this amazing gift this by simply trusting in Jesus, confessing that GOD raised him from the dead, turning away from your sins and forming a relationship with GOD.
super
thank you