DATAONLINE.IO.VN

https://365.io.vn

Java Gradle Unicode UFT-8 ​​​​​​​Apache NetBeans IDE

Java Gradle Unicode UFT-8 Apache NetBeans IDE.
Cấu trúc thư mục Project (Tệp demo kèm theo) cuối bài viết.
class frmMain 
package mygradleUnicode;

import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import nhitruc.com.function.Function;
public class frmMain {

    private JFrame mainFrame;
    private JLabel headerLabel;
    private JLabel statusLabel;
    private JPanel controlPanel;
    private JLabel msglabel;

    public frmMain() {
        prepareGUI();
    }

    private void prepareGUI() {
        mainFrame = new JFrame("Unicode UTF-8 JFrame trong Java Swing");
        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        mainFrame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent windowEvent) {
            }
        });
        mainFrame.setLayout(new GridLayout(3, 1));
        mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        headerLabel = new JLabel("", JLabel.CENTER);
        statusLabel = new JLabel("", JLabel.CENTER);
        statusLabel.setSize(350, 100);
        msglabel = new JLabel("Chào mừng bạn đến với Java Gradle", JLabel.CENTER);
        controlPanel = new JPanel();
        controlPanel.setLayout(new FlowLayout());
        mainFrame.add(headerLabel);
        mainFrame.add(controlPanel);
        mainFrame.add(statusLabel);
        mainFrame.pack();
        mainFrame.setSize(800, 400);
        mainFrame.setLocationRelativeTo(null);
        mainFrame.setVisible(true);

    }

    private void showJFrameDemo() {
        headerLabel.setText("JFrame Java Swing");
        final JFrame frame = new JFrame();
        double so = 250000;
        Function fun = new Function();
        frame.setTitle(fun.formatNumberGroup(so, 2).toString());
        frame.setLayout(new FlowLayout());
        frame.add(msglabel);
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent windowEvent) {
                frame.dispose();
            }
        });
        JButton okButton = new JButton("Mở Frame");
        okButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                statusLabel.setText("Một frame được hiển thị với người dùng.");
                frame.pack();
                frame.setSize(400, 200);
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            }
        });
        controlPanel.add(okButton);
        mainFrame.setVisible(true);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        frmMain demo = new frmMain();
        demo.showJFrameDemo();
    }
}
build.gradle 
import java.security.MessageDigest
import java.time.LocalDateTime;

apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'application'
apply plugin: 'java-library'

compileJava {options.encoding = "UTF-8"}   
compileTestJava {options.encoding = "UTF-8"}

mainClassName = 'mygradleUnicode.frmMain' 

repositories {
    mavenCentral()    
}
tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
}
dependencies {
    testImplementation     'junit:junit:4.13'
    /* Offline*/
    implementation files('mylibs/nhitruc.com.jar')
    // implementation files('mylibs/jOpenDocument-1.4rc2.jar')
    /*   
    implementation files('mylibs/commons-lang3-3.9.jar')
    implementation files('mylibs/itextpdf-5.5.9.jar')  
    implementation files('mylibs/commons-io-2.4.jar')
    implementation files('mylibs/commons-codec-1.13.jar')
    implementation files('mylibs/commons-math3-3.6.1.jar')
    implementation files('mylibs/core-3.3.0.jar')
    implementation files('mylibs/javase-3.3.0.jar')
    implementation files('mylibs/curvesapi-1.06.jar')    
    implementation files('mylibs/jaxb-core-2.3.0.1.jar')
    implementation files('mylibs/jaxb-impl-2.3.2.jar')
    implementation files('mylibs/commons-collections4-4.4.jar')
    implementation files('mylibs/commons-compress-1.20.jar')
    implementation files('mylibs/commons-logging-1.2.jar')           
    implementation files('mylibs/javafx.base.jar')  
    implementation files('mylibs/javafx.controls.jar') 
    implementation files('mylibs/javafx.fxml.jar') 
    implementation files('mylibs/javafx.graphics.jar') 
    implementation files('mylibs/javafx.media.jar') 
    implementation files('mylibs/javafx.swing.jar') 
    implementation files('mylibs/javafx.web.jar') 
    implementation files('mylibs/javafx-swt.jar') 
     */
    /*Online*/
   /* implementation 'org.apache.commons:commons-lang3:3.9'
    implementation 'com.itextpdf:itextpdf:5.5.9'
    implementation 'commons-io:commons-io:2.4'
    implementation 'commons-codec:commons-codec:1.13'
    implementation 'org.apache.commons:commons-math3:3.6.1'
    implementation 'com.google.zxing:core:3.3.3'
    implementation 'com.google.zxing:javase:3.3.0'
    implementation 'com.github.virtuald:curvesapi:1.06'
    implementation 'com.sun.xml.bind:jaxb-core:2.3.0.1'
    implementation("com.sun.xml.bind:jaxb-impl:2.3.0")
    implementation 'org.apache.commons:commons-collections4:4.4'
    implementation 'org.apache.commons:commons-compress:1.20'
    implementation 'commons-logging:commons-logging:1.2'     
    implementation 'org.libreoffice:libreoffice:7.1.5'
    */
}

LocalDateTime tg = LocalDateTime.now();
String projectversion1 = '2021.8.8'
String connect1 = "https://nhitruc.com";
String connect2 = "https://xn--nhitrc-tya.vn";
String generateMD5_A(String s){
    MessageDigest.getInstance("MD5").digest(s.bytes).encodeHex().toString()
}
String generateSha1_A(String s){
    MessageDigest.getInstance("SHA-1").digest(s.bytes).encodeHex().toString()
}

jar {    
    manifest {      
        attributes( 'Main-Class': mainClassName)        
    }
    from {
        //duplicatesStrategy = DuplicatesStrategy.INCLUDE
        duplicatesStrategy = DuplicatesStrategy.INCLUDE
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

tasks.named('jar') {
    manifest {       
        attributes( 'Projectname': project.name)
        attributes( 'Projectversion': projectversion1)
        attributes( 'LocalDateTime': tg)
        attributes( 'Keymd5': generateMD5_A("KeyMD512345678"))
        attributes( 'KeySha1': generateSha1_A("KeyMD512345678"))
        attributes('key': 'key123456')
        attributes('connect1':connect1)
        attributes('connect2': connect2)
    }
}
demo
 

Tác giả: Vàng Văn Quyn

Chú ý: Việc đăng lại bài viết trên ở website hoặc các phương tiện truyền thông khác mà không ghi rõ nguồn https://365.io.vn là vi phạm bản quyền
Chúng tôi đang sử dụng cookie để cung cấp cho bạn những trải nghiệm tốt nhất trên trang web này. Bằng cách tiếp tục truy cập, bạn đồng ý với Chính sách thu thập và sử dụng cookie của chúng tôi.
Bạn đã không sử dụng Site, Bấm vào đây để duy trì trạng thái đăng nhập. Thời gian chờ: 60 giây