https://github.com/dmlloyd/openjdk
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 :
Open your Netbeans IDE and create new project
Delete donate.java class and create new JFrameForm
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
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. |
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. |
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. |
save and run the project
Donate USD
Donate Steem
Donate SBD
https://gist.github.com/team2dev/464e6f51fc8a291cdb320045605f979f