Getting string from another class and transfering it to url

ArsenArsen

I need to get string from another class like: String called url is determined in Class 2 below, i need to get it and to copyUrlToFile(url, result + ""\plugins\TentMod") folder, where url is string i need to get from another class, and result is folder path from folder choser.

Class 1

package me.ArsenArsen.TentName.installer;

import java.io.File;

public class TMInstaller {

    protected Shell shlTentmodInstaller;
    private Text txtInstallerHasStarted;

    /**
     * Launch the application.
     * @param args
     */
    public static void main(String[] args) {
        try {
            TMInstaller window = new TMInstaller();
            window.open();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Open the window.
     */
    public void open() {
        Display display = Display.getDefault();
        createContents();
        shlTentmodInstaller.open();
        shlTentmodInstaller.layout();
        while (!shlTentmodInstaller.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    }

    /**
     * Create contents of the window.
     */
    protected void createContents() {
        shlTentmodInstaller = new Shell();
        shlTentmodInstaller.setImage(null);
        shlTentmodInstaller.setTouchEnabled(true);
        shlTentmodInstaller.setSize(450, 228);
        shlTentmodInstaller.setText("TentMod Installer");

        Button btnNewButton = new Button(shlTentmodInstaller, SWT.NONE);
        btnNewButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                DirectoryDialog dialog = new DirectoryDialog(shlTentmodInstaller, SWT.OPEN);
                dialog.setFilterPath("c:\\");
                dialog.setText("Select your server folder");
                String result = dialog.open();
                boolean success = (new File(result + "//" + "TentMod")).mkdirs();
                String textboxtxt = txtInstallerHasStarted.getText();
                if (!success) {
                    txtInstallerHasStarted.setText(textboxtxt + "\r\nMaking folder FAILED! Did folder exist???");
                } else {
                    txtInstallerHasStarted.setText(textboxtxt + "\r\nMaking folder SUCESS\r\nDownloading files!");
                    try {
                        URL url = new URL(Adv_Settings.class.urls);
                        File destination = new File(result + "plugins\\TentMod\\tent.schematic");
                        FileUtils.copyURLToFile(url, destination);
                    } catch (IOException e1) {
                        StringWriter sw = new StringWriter();
                        PrintWriter pw = new PrintWriter(sw);
                        e1.printStackTrace(pw);
                        String err = sw.toString();
                        txtInstallerHasStarted.setText(txtInstallerHasStarted.getText() + "\r\nINTERNAL ERROR\r\nWIEW STACK TRACE:\r\n" + err);
                    }
                }
            }

        });

        btnNewButton.setBounds(10, 10, 414, 33);
        btnNewButton.setText("Install TentMod");
        String currentDir = System.getProperty("user.dir");
        txtInstallerHasStarted = new Text(shlTentmodInstaller, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI);
        txtInstallerHasStarted.setText("Current Working Directory is: " + currentDir + "\r\nInstaller has started...\r\nWaiting for command...");
        txtInstallerHasStarted.setBounds(10, 49, 414, 104);

        Button btnNewButton_1 = new Button(shlTentmodInstaller, SWT.NONE);
        btnNewButton_1.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                Adv_Settings config = new Adv_Settings();
                config.open();

            }
        });
        btnNewButton_1.setBounds(10, 159, 127, 25);
        btnNewButton_1.setText("Settings (ADVANCED)");

        Button btnExit = new Button(shlTentmodInstaller, SWT.NONE);
        btnExit.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                shlTentmodInstaller.close();
            }
        });
        btnExit.setBounds(349, 159, 75, 25);
        btnExit.setText("Exit");

    }
}

And i need public string urls from second class:

package me.ArsenArsen.TentName.installer;

import org.eclipse.swt.widgets.Display;

public class Adv_Settings {
    private Text text;
    public String urls = new String("http://arsenovic.host56.com/tent.schematic");
    public String jar_url = new String("http://dev.bukkit.org/bukkit-plugins/tentmod/files/");
    private Text text_1;

    /**
     * Launch the application.
     * @param args
     */
    public static void main(String[] args) {
        try {
            Adv_Settings window = new Adv_Settings();
            window.open();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Open the window.
     */
    public void open() {
        Display display = Display.getDefault();
        Shell shell = new Shell();
        shell.setSize(276, 134);
        shell.setText("Advanced Settings - TentMod Installer");


        Button btnApply = new Button(shell, SWT.NONE);
        btnApply.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                if(text.getText().equals("")){
                    urls = "http://arsenovic.host56.com/tent.schematic";
                } else urls = text.getText();
                if(text_1.getText().equals("")){
                    jar_url = "http://dev.bukkit.org/bukkit-plugins/tentmod/files/";
                } else jar_url = text.getText();
            }
        });
        btnApply.setBounds(91, 64, 75, 25);
        btnApply.setText("Apply");

        Button btnOk = new Button(shell, SWT.NONE);
        btnOk.setBounds(10, 64, 75, 25);
        btnOk.setText("Ok");

        Button btnCancel = new Button(shell, SWT.NONE);
        btnCancel.setBounds(172, 64, 75, 25);
        btnCancel.setText("Cancel");

        text = new Text(shell, SWT.BORDER);
        text.setBounds(10, 10, 237, 21);
        text.setMessage("Insert your specific URL");

        text_1 = new Text(shell, SWT.BORDER);
        text_1.setBounds(10, 37, 237, 21);
        text_1.setMessage("Insert your specific URL for JAR file");

        shell.open();
        shell.layout();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    }
}

String is made public, and this is swt-mainly development with bit of apache to download files.

AJJ

Make the urls string to static variable and access the variable as className.variableName.

public class Adv_Settings {
        private Text text;
        public static String urls = new String("http://arsenovic.host56.com/tent.schematic");
        public String jar_url = new String("http://dev.bukkit.org/bukkit-plugins/tentmod/files/");
        private Text text_1;
         ...
    }
public class TMInstaller {

    protected Shell shlTentmodInstaller;
    private Text txtInstallerHasStarted;

protected void createContents() {
        .....
        URL url = new URL(Adv_Settings.urls);

}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Excel, transfering data from one cell to another

From Dev

Java Getting String from another class returning null

From Dev

VBA Transfering Values from an Excel table to a String

From Dev

Getting garbage values when transfering file from server to client in c?

From Dev

Transfering about 300gb in files from one server to another

From Dev

Getting string value from url

From Dev

Getting string value from url

From Dev

Getting Array from Another class C++

From Dev

Getting value from one activity to another class

From Dev

Getting value from GUI and using it in another class

From Dev

Getting TextBox values from another class

From Dev

Getting Error in Accessing Method from another class

From Dev

c# getting a string from textbox using get set , than sending it another class?

From Dev

Open ears text to speech (voice) not working when getting string from another class/controller (IOS, Objective c)

From Dev

c# getting a string from textbox using get set , than sending it another class?

From Dev

Getting String info from another java class rather than the same one

From Dev

Open ears text to speech (voice) not working when getting string from another class/controller (IOS, Objective c)

From Dev

Getting Reference (url link) from another cell?

From Dev

Getting Reference (url link) from another cell?

From Dev

Getting specific parts from a string to another

From Dev

Getting the type of another nested class from the same "parent" class

From Dev

Getting same class instance as attribute from another class

From Dev

Tkinter Transfering Data to another Window

From Dev

Getting port from URL string using Javascript

From Dev

Getting the URL's domain from a string in jQuery

From Dev

passing Image's url from class to another

From Dev

Getting a variable from a url in mvc from another controller

From Dev

Cannot access string from another class?

From Dev

Referencing user input string from another class?

Related Related

  1. 1

    Excel, transfering data from one cell to another

  2. 2

    Java Getting String from another class returning null

  3. 3

    VBA Transfering Values from an Excel table to a String

  4. 4

    Getting garbage values when transfering file from server to client in c?

  5. 5

    Transfering about 300gb in files from one server to another

  6. 6

    Getting string value from url

  7. 7

    Getting string value from url

  8. 8

    Getting Array from Another class C++

  9. 9

    Getting value from one activity to another class

  10. 10

    Getting value from GUI and using it in another class

  11. 11

    Getting TextBox values from another class

  12. 12

    Getting Error in Accessing Method from another class

  13. 13

    c# getting a string from textbox using get set , than sending it another class?

  14. 14

    Open ears text to speech (voice) not working when getting string from another class/controller (IOS, Objective c)

  15. 15

    c# getting a string from textbox using get set , than sending it another class?

  16. 16

    Getting String info from another java class rather than the same one

  17. 17

    Open ears text to speech (voice) not working when getting string from another class/controller (IOS, Objective c)

  18. 18

    Getting Reference (url link) from another cell?

  19. 19

    Getting Reference (url link) from another cell?

  20. 20

    Getting specific parts from a string to another

  21. 21

    Getting the type of another nested class from the same "parent" class

  22. 22

    Getting same class instance as attribute from another class

  23. 23

    Tkinter Transfering Data to another Window

  24. 24

    Getting port from URL string using Javascript

  25. 25

    Getting the URL's domain from a string in jQuery

  26. 26

    passing Image's url from class to another

  27. 27

    Getting a variable from a url in mvc from another controller

  28. 28

    Cannot access string from another class?

  29. 29

    Referencing user input string from another class?

HotTag

Archive