Browse Source

window

master
yaroslav 2 years ago
commit
1fe9caca8f
10 changed files with 206 additions and 0 deletions
  1. +10
    -0
      MyWindow/.classpath
  2. +17
    -0
      MyWindow/.project
  3. +2
    -0
      MyWindow/.settings/org.eclipse.core.resources.prefs
  4. +14
    -0
      MyWindow/.settings/org.eclipse.jdt.core.prefs
  5. BIN
      MyWindow/bin/module-info.class
  6. BIN
      MyWindow/bin/package1/Window$1.class
  7. BIN
      MyWindow/bin/package1/Window$2.class
  8. BIN
      MyWindow/bin/package1/Window.class
  9. +10
    -0
      MyWindow/src/module-info.java
  10. +153
    -0
      MyWindow/src/package1/Window.java

+ 10
- 0
MyWindow/.classpath View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

+ 17
- 0
MyWindow/.project View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MyWindow</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

+ 2
- 0
MyWindow/.settings/org.eclipse.core.resources.prefs View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

+ 14
- 0
MyWindow/.settings/org.eclipse.jdt.core.prefs View File

@ -0,0 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17

BIN
MyWindow/bin/module-info.class View File


BIN
MyWindow/bin/package1/Window$1.class View File


BIN
MyWindow/bin/package1/Window$2.class View File


BIN
MyWindow/bin/package1/Window.class View File


+ 10
- 0
MyWindow/src/module-info.java View File

@ -0,0 +1,10 @@
/**
*
*/
/**
* @author yaros
*
*/
module MyWindow {
requires java.desktop;
}

+ 153
- 0
MyWindow/src/package1/Window.java View File

@ -0,0 +1,153 @@
package package1;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.awt.Button;
import javax.swing.JTextPane;
import javax.swing.SwingWorker;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JProgressBar;
import java.awt.Font;
public class Window extends SwingWorker<Object, Object>{
private JFrame frame;
private JTextField tfOriginal;
private JTextField tfCopy;
private JProgressBar progressBar;
private JLabel lbResult;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Window window = new Window();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Window() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
frame.getContentPane().add(panel, BorderLayout.CENTER);
panel.setLayout(null);
Button button = new Button("Copy");
button.setBounds(176, 84, 70, 22);
panel.add(button);
JTextPane textPane = new JTextPane();
textPane.setText(" --->");
textPane.setBackground(new Color(192, 192, 192));
textPane.setBounds(186, 56, 54, 20);
panel.add(textPane);
JLabel lblNewLabel = new JLabel("WARNING: Please put the absolute route with the file name and extention");
lblNewLabel.setBounds(24, 11, 379, 35);
panel.add(lblNewLabel);
tfOriginal = new JTextField();
tfOriginal.setToolTipText("Original File");
tfOriginal.setColumns(10);
tfOriginal.setBounds(24, 56, 153, 20);
panel.add(tfOriginal);
tfCopy = new JTextField();
tfCopy.setToolTipText("Copied File");
tfCopy.setColumns(10);
tfCopy.setBounds(250, 56, 153, 20);
panel.add(tfCopy);
progressBar = new JProgressBar();
progressBar.setBounds(24, 179, 379, 22);
panel.add(progressBar);
lbResult = new JLabel("");
lbResult.setFont(new Font("Tahoma", Font.BOLD, 13));
lbResult.setBounds(186, 132, 106, 31);
panel.add(lbResult);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
operacion();
}
});
}
public void operacion() {
try{
FileInputStream input = new FileInputStream(tfOriginal.getText());
FileOutputStream output = new FileOutputStream(tfCopy.getText());
byte[] complet = input.readAllBytes();
progressBar.setMinimum(0);
progressBar.setMaximum(complet.length);
for(int i = 0; i < complet.length; i++) {
output.write(complet[i]);
lbResult.setText("1");
Thread.sleep(50);
lbResult.setText("2");
progressBar.setValue(i + 1);
progressBar.update(progressBar.getGraphics());
}
lbResult.setText("Copied");
} catch (FileNotFoundException e) {
lbResult.setText("FileError");
e.printStackTrace();
} catch (IOException e) {
lbResult.setText("Error");
e.printStackTrace();
} catch (InterruptedException e) {
lbResult.setText("ThreadError");
e.printStackTrace();
}
}
@Override
protected Object doInBackground() throws Exception {
lbResult.setText("xd");
return null;
}
}

Loading…
Cancel
Save