From 1fe9caca8fc663702ba836133085f8615c1b8fae Mon Sep 17 00:00:00 2001 From: yaroslav Date: Sun, 16 Oct 2022 19:54:21 +0200 Subject: [PATCH] window --- MyWindow/.classpath | 10 ++ MyWindow/.project | 17 ++ .../org.eclipse.core.resources.prefs | 2 + MyWindow/.settings/org.eclipse.jdt.core.prefs | 14 ++ MyWindow/bin/module-info.class | Bin 0 -> 171 bytes MyWindow/bin/package1/Window$1.class | Bin 0 -> 797 bytes MyWindow/bin/package1/Window$2.class | Bin 0 -> 681 bytes MyWindow/bin/package1/Window.class | Bin 0 -> 4262 bytes MyWindow/src/module-info.java | 10 ++ MyWindow/src/package1/Window.java | 153 ++++++++++++++++++ 10 files changed, 206 insertions(+) create mode 100644 MyWindow/.classpath create mode 100644 MyWindow/.project create mode 100644 MyWindow/.settings/org.eclipse.core.resources.prefs create mode 100644 MyWindow/.settings/org.eclipse.jdt.core.prefs create mode 100644 MyWindow/bin/module-info.class create mode 100644 MyWindow/bin/package1/Window$1.class create mode 100644 MyWindow/bin/package1/Window$2.class create mode 100644 MyWindow/bin/package1/Window.class create mode 100644 MyWindow/src/module-info.java create mode 100644 MyWindow/src/package1/Window.java diff --git a/MyWindow/.classpath b/MyWindow/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/MyWindow/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/MyWindow/.project b/MyWindow/.project new file mode 100644 index 0000000..92876fd --- /dev/null +++ b/MyWindow/.project @@ -0,0 +1,17 @@ + + + MyWindow + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/MyWindow/.settings/org.eclipse.core.resources.prefs b/MyWindow/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/MyWindow/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/MyWindow/.settings/org.eclipse.jdt.core.prefs b/MyWindow/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/MyWindow/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/MyWindow/bin/module-info.class b/MyWindow/bin/module-info.class new file mode 100644 index 0000000000000000000000000000000000000000..93814935d3e048610abd15d3a69807b187abc5da GIT binary patch literal 171 zcmX^0Z`VEs1_oOO9(D#MMh5QO{FKt1RNc(Hw0uSeuHgLAqU2P!%$!t41_2}~y{yEt zL`DWSU$AOn26jdU4&Tb~%)FHRa$yEeMg|^`0=<;f;_QNK#^PY6AlU jBhX3+U}9hfGME@x7+8U{3Y%KR%Nf zNHp;W_@j(xw+$$6GCMQ(-Z}T4bMLR;-+uylh9@>M0>zQ^Kgqt@^4@CG3y#;fY*+#d zNAk1u2GaDs*WDxK$2MjJN|)9*V`F4@paf=~YNO-l0@-S?*af(sjYf%%p; zYJWWJs_aXY4(2ch&6U6`4IQsS$WNJubXDJ^j#@&z1yb1BN698HyR z+QB&V)viv|E==0AnN&hKc8os=B2wH_@nO(&@d%IEgQ3($V7dC?uN3W=751A+kKC8W zsBn8AqexNn{Jx6f7eN%G0&2~bx_JDBUv&W5ZC|hS(`HFn2afUmm>C*))QtB*$z-A^j)Cf^0Py=N$ zTft_UsKOY6O%vrAb06zOD8s@7Z1D7uevWtB#+pTAmDdcx>f9|3OM^gw!@z`6@_Aet G6#oF)*rCh- literal 0 HcmV?d00001 diff --git a/MyWindow/bin/package1/Window$2.class b/MyWindow/bin/package1/Window$2.class new file mode 100644 index 0000000000000000000000000000000000000000..e798c2c0f1d39bde3440f75d99df5281dccd1e85 GIT binary patch literal 681 zcmaJ;ZA%+L5PmjEbIEya;!8DJtyWWrDR`~)n^hFCC|s?eq@OpJXTOVT#niLEj^Qkf-9sX*DDs;v2zS)&o!4Zi%Kw6a?Q zQ?37QS33fwUDKl~1fB-)Q1MYjEkG4@fnv)Q)FP$n@Z!8n>51$nBrp+~SSB5rDi;rv zB_~2)aaGp1@)&dT^>eH{r%=$43Km9%dOkGE;yTPF&RtD3viU zLO`&n`N#MK{9|*G#`ICS0mkl^zUCBggFPK5CR4iqiR`KA1z2_se783x6Lrmq;6U@L zcN3Xq#8XxdDYN?~vsmKI71^FZ)a!16{Ky5iDtyk4vG<;1m+{+gej;f9##bzM8PO0>IB}D)#TaeMj9AIRrnU0B-brsZ z(+U*>X=B(_sEU`WtZox&vqH!n=t^6IR?@H)=9TO8n4@l+W!eeq&2R@=ozzx^%2e7J zOq-cZi$U)vm0PSiI!BwJ-PdhqvbH-VdfezUZE6ID4J)ZIw|0Z)r^z-XeK*bgo9otb zzST*X8lno3V^)3UxgkVQrK1{incbyU(sGw7Os}n57s5Q8q+!0o39{rSW5jJ*xy4Mn zS7pttspDjv!ev;=EzV{$Zn#pU6KhN2cW0AHqt7+!y9ONgwBM_Pc~f z5?i5TCEEPO$BnH{mfd!8i3eZSVI;X_(zMZV1@};~F

&>m-9%?KN9!YY3|lm#*qi zs4ne_VpobrOd_w5tglk2FNxOb6!I-ANI|G!E!~!ZDw|A-7(zFyf?(6ntdUPF7F#N^ zYjpHVG8(}XT@4!uKr#PT$97oTYq3$1ek;o@z)NYmalH-$eG0RrF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F8l`A7 zdV_B@TCf_8;Ei&#(Y)ChgWY@p+i12eJTHPLB_FQwR`Iuq%hVM8tJQFdp6%ULY$GiC8vHVs|f*yf26Qj{*v(1=#H z&}uVIhv2(1Bg(#64JphjA75@dmaZJ(#5Cb6AHLupTet8vL4< zwbyC+2Ch@nu~Aj=)^;kcSG6$ICA_Y+AfdW=5$nT%%JAYf221Tg+H0l@{D#RlQ={65 zhZsxoO1m8I!~5A@{pu`y03T!{K8)A!A#Q^J=N~CFoqCZoa?Tu@#GYOjfzUiUfse%} zu}@xEa=t#+(U8OAoqXRmJ%{}=#t!H3LyqF{=+ik&R^c-TaoBr( zj<2F#9SB^X!x!aIzBzm)hZn{JsyYxm{K%1KJlz+myBFt6OOHpt%@+p!?p~bX3x4Pe ze!Q1=2v6guzToFic$;iHcJhb;FH{e)sxm%?S2!bkxsU$POdrz2dGrPkj0_Gml}$5hhxpL21~dVV{QA$vDkN5ETjON5e~NG`!63D+2Ie@K*-=8%+i5 zzn8O}SG<3+cxpctrg;_e+3tSQ;{)DG3T)?-Q~>|>G~d8~yz#&IAIB(dBOK+k+aK^I K#~Ge{_x}OnNmyL~ literal 0 HcmV?d00001 diff --git a/MyWindow/src/module-info.java b/MyWindow/src/module-info.java new file mode 100644 index 0000000..e59feda --- /dev/null +++ b/MyWindow/src/module-info.java @@ -0,0 +1,10 @@ +/** + * + */ +/** + * @author yaros + * + */ +module MyWindow { + requires java.desktop; +} \ No newline at end of file diff --git a/MyWindow/src/package1/Window.java b/MyWindow/src/package1/Window.java new file mode 100644 index 0000000..a028ab4 --- /dev/null +++ b/MyWindow/src/package1/Window.java @@ -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{ + + 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; + } +}