JavaTutorial #13 : How to create Donate Page (USD, STEEM, SBD) in Java Aplication using Netbeans IDE
Repository
https://github.com/dmlloyd/openjdk
What Will I Learn?
- You will learn about steemconnect link to transfer SBD and STEEM
- You will learn about Paypal link to transfer USD
- You will learn how to create form for this application
- You will learn how to combine data from the form to the link
Requirements
- NetBeans IDE Software
- Basic Knowledge about Java Programing and Netbeans
Difficulty
- Basic
Tutorial Contents
In an application, a programmer usually provides a page for donations. Usually they use USD, Bitcoin, Etherium or other currencies. Here I will try to make a donation page for java application using USD, STEEM and SBD. for STEEM and SBD, I use steemconnect. As for USD, use Paypal. I hope this becomes a reference for those of you who are java language programmers.
Directly, Lets follow steps bellow to create this application :
Create a form
Open your Netbeans IDE and create new project
Delete
donate.java
class and create new JFrameForm
Design the Form
Add jLabel for the title
Add TabbedPane to create donation tabs
Add 3 panel on TabbedPane, For USD, STEEM and SBD donation
Create form for tab1, tab2, and tab3. Tab1 for USD, Tab2 for STEEM and tab3 for SBD. The form contain 2 textfield and 1 button, like image bellow :
Rename the textfield and button with different variable name. You can see my variable
Edit Source Code
open donate usd tab on design and double click on send button until appear like image bellow then add some method
Right click on hint simbol on left side on code and click on
add donateUsd method
Go to
donateUSD()
method and add the code bellow :
String usdR=usdReceiver.getText();
String usd=usdAmount.getText();
final JFrame frame=new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(1280,720);
final JFXPanel fxpanel=new JFXPanel();
frame.add(fxpanel);
Platform.runLater(new Runnable(){
@Override
public void run() {
WebEngine engine;
WebView wv =new WebView();
engine=wv.getEngine();
fxpanel.setScene(new Scene(wv));
engine.load("https://www.paypal.me/"+usdR+"/"+usd+"USD");
}
});
frame.setVisible(true);
Code | Explanation |
---|---|
usdReceiver.getText() | get text from receiver textfield |
usdAmount.getText() | get text from amount textfield |
frame | the variable name for new JFrame. You need to import package javax.swing.JFrame for using JFrame |
setDefaultCloseOperation | method to set the the exit button on right-top corner |
setSize() | method to set the width and height of the new frame |
final JFXPanel fxpanel=new JFXPanel() | Initialize new JFX panel |
frame.add(fxpanel) | add JfxPanel to JFrame |
Platform.runLater | method to run some task on JFXpanel |
@Override | to implement all abstract method |
WebEngine engine | Inizialize web engine |
WebView wv =new WebView() | Inizialize new web view |
engine=wv.getEngine() | get view from web engine |
fxpanel.setScene(new Scene(wv)) | set scene on JFXpanel |
engine.load | load some url |
https://www.paypal.me/"+usdR+"/"+usd+"USD | Paypal.me link to get USD. Here we costume it with receiver and amount in input from form. |
- Now go to donate steem tab and double click on send button and add
donateSteem()
method then add this code in that method, like this :
private void donateSteem() {
String steemR=steemReceiver.getText();
String steem=steemAmount.getText();
final JFrame frame=new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(1280,720);
final JFXPanel fxpanel=new JFXPanel();
frame.add(fxpanel);
Platform.runLater(new Runnable(){
@Override
public void run() {
WebEngine engine;
WebView wv =new WebView();
engine=wv.getEngine();
fxpanel.setScene(new Scene(wv));
engine.load("https://steemconnect.com/sign/transfer?from=you&to="+steemR+"&amount="+steem+"%20STEEM&memo=Donations");
}
});
frame.setVisible(true);
}
Code | Explanation |
---|---|
steemReceiver.getText() | get text from receiver textfield for STEEM |
steemAmount.getText() | get text from amount textfield for STEEM |
https://steemconnect.com/sign/transfer?from=you&to="+steemR+"&amount="+steem+"%20STEEM&memo=Donations | steemconnect link for transferring STEEM to another account. here I costume the link for the to and amount value are from the user input and I set Donations for memo value. |
- Last one go to Donate SBD tab then do as you do on Donate SBD tab. and add the code bellow in
donateSBD()
method :
String sbdR=sbdReceiver.getText();
String sbd=sbdAmount.getText();
final JFrame frame=new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(1280,720);
final JFXPanel fxpanel=new JFXPanel();
frame.add(fxpanel);
Platform.runLater(new Runnable(){
@Override
public void run() {
WebEngine engine;
WebView wv =new WebView();
engine=wv.getEngine();
fxpanel.setScene(new Scene(wv));
engine.load("https://steemconnect.com/sign/transfer?from=you&to="+sbdR+"&amount="+sbd+"%20SBD&memo=Donations");
}
});
frame.setVisible(true);
Code | Explanation |
---|---|
sbdReceiver.getText() | get text from receiver textfield for SBD |
sbdAmount.getText() | get text from amount textfield for SBD |
https://steemconnect.com/sign/transfer?from=you&to="+steemR+"&amount="+steem+"%20SBD&memo=Donations | steemconnect link for transferring SBD to another account. here I costume the link for the to and amount value are from the user input and I set Donations for memo value. |
Testing and Running the App
save and run the project
Donate USD
Donate Steem
Donate SBD
Curriculum
- JavaTutorial #10 : How to create Maps Aplication (Google Maps in Desktop Version) with java using Netbeans
- JavaTutorial #11 : How to create Delegating SP aplication using java Netbeans IDE
- JavaTutorial #12 :How to encrypt and descrypt txt file with AES in java programing
Proof of Work Done
https://gist.github.com/team2dev/464e6f51fc8a291cdb320045605f979f
Thank you for your contribution @team2dev.
Below are the points we suggest for improvements to your tutorial:
We suggest you explain in more detail in your tutorial. It is important to have theory about what you are developing.
In code it is very important to have comments explaining what certain lines of code do. For the reader it facilitates the interpretation of the code that is developing.
Improve the structure of the tutorial.
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Thank you for your review, @portugalcoin! Keep up the good work!
Hi @team2dev!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Hey, @team2dev!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!