Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.73 KB | None | 0 0
  1. package com.amazonaws.samples;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Dimension;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.io.File;
  8. import java.io.FileNotFoundException;
  9. import java.io.FileOutputStream;
  10. import java.io.IOException;
  11. import java.util.List;
  12.  
  13. import javax.swing.BorderFactory;
  14. import javax.swing.BoxLayout;
  15. import javax.swing.JButton;
  16. import javax.swing.JComboBox;
  17. import javax.swing.JFileChooser;
  18. import javax.swing.JFrame;
  19. import javax.swing.JLabel;
  20. import javax.swing.JOptionPane;
  21. import javax.swing.JPanel;
  22. import javax.swing.JProgressBar;
  23. import javax.swing.JTextArea;
  24. import javax.swing.JTextField;
  25.  
  26. import com.amazonaws.AmazonClientException;
  27. import com.amazonaws.AmazonServiceException;
  28. import com.amazonaws.SdkClientException;
  29. import com.amazonaws.auth.AWSCredentials;
  30. import com.amazonaws.auth.AWSStaticCredentialsProvider;
  31. import com.amazonaws.auth.profile.ProfileCredentialsProvider;
  32. import com.amazonaws.event.ProgressEvent;
  33. import com.amazonaws.event.ProgressListener;
  34. import com.amazonaws.samples.S3TransferProgressSample.ButtonListener;
  35. import com.amazonaws.services.s3.AmazonS3;
  36. import com.amazonaws.services.s3.AmazonS3ClientBuilder;
  37. import com.amazonaws.services.s3.model.Bucket;
  38. import com.amazonaws.services.s3.model.ListObjectsV2Request;
  39. import com.amazonaws.services.s3.model.ListObjectsV2Result;
  40. import com.amazonaws.services.s3.model.ObjectListing;
  41. import com.amazonaws.services.s3.model.PutObjectRequest;
  42. import com.amazonaws.services.s3.model.S3Object;
  43. import com.amazonaws.services.s3.model.S3ObjectInputStream;
  44. import com.amazonaws.services.s3.model.S3ObjectSummary;
  45. import com.amazonaws.services.s3.transfer.TransferManager;
  46. import com.amazonaws.services.s3.transfer.TransferManagerBuilder;
  47. import com.amazonaws.services.s3.transfer.Upload;
  48.  
  49. public class lab2v2 {
  50.     private static AWSCredentials credentials;
  51.     private static TransferManager tx;
  52.     private static AmazonS3 s3;
  53.     private static String bucketName;
  54.    
  55.     private JPanel leftPanel, rightPanel, row1Panel, row2Panel, row3Panel, row21Panel, row22Panel, row23Panel, row24Panel, row25Panel, mainPanel;
  56.     private JProgressBar progressBar;
  57.     private JFrame frame;
  58.     private Upload upload;
  59.     private JButton clearObjectListBtn, createBucketBtn, listBucketsBtn, listObjectsBtn, uploadBtn, deleteBtn, dowloadBtn, clearBucketListTA;
  60.     private JLabel regionLabel, bucketLabel, bucket2Label;
  61.     private JTextField regionNameTF, bucketNameTF, bucket2NameTF, fileToDeleteTF, fileToDownloadTF;
  62.     private JTextArea bucketList, objectList;
  63.     private JComboBox<String> regionsCB;
  64.    
  65.     private static String OS = System.getProperty("os.name").toLowerCase();
  66.     private static String desktop_path = "";
  67.    
  68.     private static long uploadDur;
  69.    
  70.     private String[] regions = new String[] {
  71.             "eu-central-1",
  72.             "eu-west-1",
  73.             "eu-west-2",
  74.             "eu-west-3",
  75.             "us-east-1",
  76.             "us-east-2",
  77.             "us-west-1",
  78.             "us-west-2",
  79.             "ap-northeast-1",
  80.             "ap-northeast-2",
  81.             "ap-southeast-1",
  82.             "ap-southeast-2",
  83.             "ca-central-1"};
  84.    
  85.     public static boolean isWindows() {
  86.  
  87.         return (OS.indexOf("win") >= 0);
  88.  
  89.     }
  90.    
  91.     public static boolean isMac() {
  92.  
  93.         return (OS.indexOf("mac") >= 0);
  94.  
  95.     }
  96.    
  97.     public static boolean isUnix() {
  98.  
  99.         return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 );
  100.        
  101.     }
  102.    
  103.     public static void main(String[] args) throws Exception {
  104.        
  105.         desktop_path = System.getProperty("user.home") + "/Desktop";
  106.         System.out.println(desktop_path);
  107.        
  108.         if (isWindows()) {
  109.             System.out.println("This is Windows");
  110.            
  111.         } else if (isMac()) {
  112.             System.out.println("This is Mac");
  113.         } else if (isUnix()) {
  114.             System.out.println("This is Unix or Linux");
  115.         } else {
  116.             System.out.println("Your OS is not support!!");
  117.         }
  118.        
  119.        
  120.         try {
  121.         credentials = new ProfileCredentialsProvider("default").getCredentials();
  122.         }
  123.         catch(Exception e){
  124.             throw new AmazonClientException(
  125.                     "Cannot load the credentials from the credential profiles file. " +
  126.                     "Please make sure that your credentials file is at the correct " +
  127.                     "location (/Users/meru/.aws/credentials), and is in valid format.",
  128.                     e);
  129.         }
  130.        
  131.         s3 = AmazonS3ClientBuilder.standard()
  132.                 .withCredentials(new AWSStaticCredentialsProvider(credentials))
  133.                 .withRegion("eu-west-2")
  134.                 .build();
  135.        
  136.         tx = TransferManagerBuilder.standard()
  137.                 .withS3Client(s3)
  138.                 .build();
  139.        
  140.         bucketName = "s3-upload-sdk-sample-fas-mn";
  141.         new lab2v2();
  142.        
  143.     }
  144.      
  145.     public lab2v2() throws Exception {
  146.         frame = new JFrame("Amazon S3 File CRUD");
  147.        
  148.         //left side
  149.         regionLabel = new JLabel("Region         ");
  150.         regionLabel.setPreferredSize(new Dimension(200, 30));
  151.        
  152.         regionsCB = new JComboBox<>(regions);
  153.         regionsCB.setPreferredSize(new Dimension(200, 30));
  154.        
  155.         listBucketsBtn = new JButton("List buckets");
  156.         listBucketsBtn.setPreferredSize(new Dimension(200, 30));
  157.         listBucketsBtn.addActionListener(new ActionListener() {
  158.             public void actionPerformed(ActionEvent evt) {
  159.                 bucketList.append("\nGlobal bucket list:\n");
  160.                 try {
  161.                     for (Bucket bucket : s3.listBuckets()) {
  162.                         bucketList.append(" - " + bucket.getName()+ "\n");
  163.                     }
  164.                     bucketList.append("\n");
  165.                 } catch (Exception ace) {
  166.                     bucketList.append("ERROR LISTING BUCKETS\n"+ ace.getMessage()+"\n");
  167.                     System.out.println("Error Message: " + ace.getMessage());
  168.                 }
  169.             }
  170.         });
  171.        
  172.         bucketLabel = new JLabel("       Bucket name");
  173.         bucketLabel.setPreferredSize(new Dimension(200, 30));
  174.         bucketNameTF = new JTextField();
  175.         bucketNameTF.setPreferredSize(new Dimension(200, 30));
  176.        
  177.         createBucketBtn = new JButton("Create");
  178.         createBucketBtn.setPreferredSize(new Dimension(200, 30));
  179.         createBucketBtn.addActionListener(new ActionListener() {
  180.             public void actionPerformed(ActionEvent evt) {
  181.                 String regionSelected =  regionsCB.getSelectedItem().toString();
  182.                 AmazonS3 s3local = AmazonS3ClientBuilder.standard()
  183.                         .withCredentials(new AWSStaticCredentialsProvider(credentials))
  184.                         .withRegion(regionSelected)
  185.                         .build();
  186.                 try {
  187.                     bucketName = bucketNameTF.getText();
  188.                     if (bucketName.equals("")) {
  189.                         JOptionPane.showMessageDialog(frame,
  190.                                 "Bucketname is invalid or empty",
  191.                                 "Error creating bucket", JOptionPane.ERROR_MESSAGE);
  192.                     } else {
  193.                         bucketList.append("Creating bucket " + bucketName + "\n");
  194.                         s3local.createBucket(bucketName);
  195.                     }
  196.                 }
  197.                 catch (Exception ace) {
  198.                     JOptionPane.showMessageDialog(frame,
  199.                             ace.getMessage(),
  200.                             "Error creating bucket...", JOptionPane.ERROR_MESSAGE);
  201.                 }
  202.                
  203.             }
  204.         });
  205.        
  206.         clearBucketListTA = new JButton("CLR");
  207.         clearBucketListTA.setPreferredSize(new Dimension(100, 30));
  208.         clearBucketListTA.addActionListener(new ActionListener() {
  209.             public void actionPerformed(ActionEvent evt) {
  210.                 bucketList.setText("");
  211.             }
  212.         });
  213.        
  214.         bucketList = new JTextArea();
  215.         bucketList.setPreferredSize(new Dimension(600, 700));
  216.        
  217.         //right side -----------------------------------------
  218.        
  219.         objectList = new JTextArea();
  220.         objectList.setPreferredSize(new Dimension(600, 650));
  221.        
  222.         bucket2Label = new JLabel("Bucket name");
  223.         bucket2Label.setPreferredSize(new Dimension(200, 30));
  224.         bucket2NameTF = new JTextField();
  225.         bucket2NameTF.setPreferredSize(new Dimension(200, 30));
  226.        
  227.         listObjectsBtn = new JButton("List objects");
  228.         listObjectsBtn.setPreferredSize(new Dimension(200, 30));
  229.         listObjectsBtn.addActionListener(new ActionListener() {
  230.             public void actionPerformed(ActionEvent evt) {
  231.                            
  232.                 if (!bucket2NameTF.getText().toString().isEmpty()) {
  233.                     String clientRegion = regionsCB.getSelectedItem().toString();
  234.                     String bucketName = bucket2NameTF.getText().toString();
  235.                     objectList.setText("");
  236.                     try {    
  237.                         AmazonS3 s3Initial = AmazonS3ClientBuilder.standard()
  238.                                 .withCredentials(new AWSStaticCredentialsProvider(credentials))
  239.                                 .withRegion(clientRegion)
  240.                                 .build();
  241.                        
  242.                         String location = s3Initial.getBucketLocation(bucketName);
  243.                        
  244.                         AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
  245.                                 .withCredentials(new AWSStaticCredentialsProvider(credentials))
  246.                                 .withRegion(location)
  247.                                 .build();
  248.                
  249.                         // maxKeys is set to 2 to demonstrate the use of
  250.                         // ListObjectsV2Result.getNextContinuationToken()
  251.                         ListObjectsV2Request req = new ListObjectsV2Request().withBucketName(bucketName).withMaxKeys(2);
  252.                         ListObjectsV2Result result;
  253.  
  254.                         do {
  255.                             result = s3Client.listObjectsV2(req);
  256.                
  257.                             for (S3ObjectSummary objectSummary : result.getObjectSummaries()) {
  258.                                
  259.                                 objectList.append(" - "+objectSummary.getKey()+" (size: "+objectSummary.getSize()+")\n");
  260.                             }
  261.                             // If there are more than maxKeys keys in the bucket, get a continuation token
  262.                             // and list the next objects.
  263.                             String token = result.getNextContinuationToken();
  264.                             System.out.println("Next Continuation Token: " + token);
  265.                             req.setContinuationToken(token);
  266.                         } while (result.isTruncated());
  267.                     }
  268.                     catch(Exception e) {
  269.                         // The call was transmitted successfully, but Amazon S3 couldn't process
  270.                         // it, so it returned an error response.
  271.                         objectList.append(e.getMessage());
  272.                         //e.printStackTrace();
  273.                     }
  274.                 } else {
  275.                     JOptionPane.showMessageDialog(frame,
  276.                             "Bucketname is invalid or empty!",
  277.                             "Error fetching bucket contents.", JOptionPane.ERROR_MESSAGE);
  278.                 }
  279.                
  280.             }
  281.         });
  282.        
  283.         clearObjectListBtn = new JButton("CLR");
  284.         clearObjectListBtn.setPreferredSize(new Dimension(200, 30));
  285.         clearObjectListBtn.addActionListener(new ActionListener() {
  286.             public void actionPerformed(ActionEvent evt) {
  287.                 objectList.setText("");
  288.             }
  289.         });
  290.        
  291.         uploadBtn = new JButton("Choose & Upload...");
  292.         uploadBtn.addActionListener(new ButtonListener());
  293.         uploadBtn.setPreferredSize(new Dimension(200, 30));
  294.        
  295.  
  296.         progressBar = new JProgressBar(0, 100);
  297.         progressBar.setStringPainted(true);
  298.         progressBar.setPreferredSize(new Dimension(200, 30));
  299.  
  300.         fileToDownloadTF = new JTextField();
  301.         fileToDownloadTF.setPreferredSize(new Dimension(200, 30));
  302.        
  303.         dowloadBtn = new JButton("Download");
  304.         dowloadBtn.setPreferredSize(new Dimension(200, 30));
  305.         dowloadBtn.addActionListener(new ActionListener() {
  306.             public void actionPerformed(ActionEvent evt) {
  307.                 if (!fileToDownloadTF.getText().isEmpty() && !bucket2NameTF.getText().isEmpty()) {
  308.                     String clientRegion = regionsCB.getSelectedItem().toString();
  309.                     String bucketName = bucket2NameTF.getText().toString();
  310.                    
  311.                     AmazonS3 s3Initial = AmazonS3ClientBuilder.standard()
  312.                             .withCredentials(new AWSStaticCredentialsProvider(credentials))
  313.                             .withRegion(clientRegion)
  314.                             .build();
  315.                    
  316.                     String location = s3Initial.getBucketLocation(bucketName);
  317.                    
  318.                     AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
  319.                             .withCredentials(new AWSStaticCredentialsProvider(credentials))
  320.                             .withRegion(location)
  321.                             .build();
  322.                    
  323.                     String key_name = fileToDownloadTF.getText().toString();
  324.                     long duration = 0;
  325.                    
  326.                     System.out.format("Downloading %s from S3 bucket %s...\n", key_name, bucketName);
  327.                     try {
  328.                        
  329.                         long startTime = System.nanoTime();
  330.                         //////////MEASURE TIME//////////
  331.                         S3Object o = s3Client.getObject(bucketName, key_name);
  332.                         S3ObjectInputStream s3is = o.getObjectContent();
  333.                        
  334.                         String[] parts = key_name.split("/");
  335.                         if (key_name.contains("/")) {
  336.                             key_name = parts[parts.length-1];
  337.                         }
  338.                        
  339.                         FileOutputStream fos = new FileOutputStream(new File(desktop_path+"/"+key_name));
  340.                         byte[] read_buf = new byte[1024];
  341.                         int read_len = 0;
  342.                         while ((read_len = s3is.read(read_buf)) > 0) {
  343.                             fos.write(read_buf, 0, read_len);
  344.                         }
  345.                         ////////////////////////////////
  346.                         long endTime = System.nanoTime();
  347.                         duration = (endTime - startTime);  //divide by 1000000 to get millisecond
  348.                         objectList.append("\nFetching "+key_name+" from bucket "+bucketName+" in "+location+" took: " + duration/1000000 + "ms");
  349.                         s3is.close();
  350.                         fos.close();
  351.                     } catch (Exception e) {
  352.                         JOptionPane.showMessageDialog(frame,
  353.                                 "ERROR: "+e.getMessage(),
  354.                                 "Error downloading File", JOptionPane.ERROR_MESSAGE);
  355.                         return;
  356.                     }
  357.                 } else {
  358.                     JOptionPane.showMessageDialog(frame,
  359.                             "Filename is invalid or empty",
  360.                             "Error downloading File", JOptionPane.ERROR_MESSAGE);
  361.                 }
  362.             }
  363.         });
  364.        
  365.         fileToDeleteTF = new JTextField();
  366.         fileToDeleteTF.setPreferredSize(new Dimension(200, 30));
  367.         deleteBtn = new JButton("Delete");
  368.         deleteBtn.setPreferredSize(new Dimension(200, 30));
  369.         deleteBtn.addActionListener(new ActionListener() {
  370.             public void actionPerformed(ActionEvent evt) {
  371.                 if (!fileToDeleteTF.getText().isEmpty() && !bucket2NameTF.getText().isEmpty()) {
  372.                    
  373.                     String clientRegion = regionsCB.getSelectedItem().toString();
  374.                     String bucketName = bucket2NameTF.getText().toString();
  375.                     String key_name = fileToDeleteTF.getText().toString();
  376.                    
  377.                     AmazonS3 s3Initial = AmazonS3ClientBuilder.standard()
  378.                             .withCredentials(new AWSStaticCredentialsProvider(credentials))
  379.                             .withRegion(clientRegion)
  380.                             .build();
  381.                    
  382.                     String location = s3Initial.getBucketLocation(bucketName);
  383.                    
  384.                     AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
  385.                             .withCredentials(new AWSStaticCredentialsProvider(credentials))
  386.                             .withRegion(location)
  387.                             .build();
  388.                    
  389.                     try {
  390.                         s3Client.deleteObject(bucketName, key_name);
  391.                     } catch (AmazonServiceException e) {
  392.                         System.err.println(e.getErrorMessage());
  393.                         System.exit(1);
  394.                     }
  395.                     JOptionPane.showMessageDialog(frame,
  396.                             "File deleted successfully!",
  397.                             "Finished", JOptionPane.INFORMATION_MESSAGE);
  398.                 } else {
  399.                     JOptionPane.showMessageDialog(frame,
  400.                             "Filename is invalid or empty",
  401.                             "Error deleting File", JOptionPane.ERROR_MESSAGE);
  402.                 }
  403.             }
  404.         });
  405.        
  406.        
  407.         frame.setContentPane(createContentPane());
  408.         frame.pack();
  409.         frame.setVisible(true);
  410.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  411.     }
  412.    
  413.     class ButtonListener implements ActionListener {
  414.         public void actionPerformed(ActionEvent ae) {
  415.             String clientRegion = regionsCB.getSelectedItem().toString();
  416.             String bucketName2 = bucket2NameTF.getText().toString();
  417.            
  418.             AmazonS3 s3Initial = AmazonS3ClientBuilder.standard()
  419.                     .withCredentials(new AWSStaticCredentialsProvider(credentials))
  420.                     .withRegion(clientRegion)
  421.                     .build();
  422.            
  423.             String location = s3Initial.getBucketLocation(bucketName2);
  424.            
  425.             AmazonS3 s3client = AmazonS3ClientBuilder.standard()
  426.                     .withCredentials(new AWSStaticCredentialsProvider(credentials))
  427.                     .withRegion(location)
  428.                     .build();
  429.            
  430.            
  431.             TransferManager txclient = TransferManagerBuilder.standard()
  432.                     .withS3Client(s3client)
  433.                     .build();
  434.            
  435.             JFileChooser fileChooser = new JFileChooser();
  436.             int showOpenDialog = fileChooser.showOpenDialog(frame);
  437.             if (showOpenDialog != JFileChooser.APPROVE_OPTION) return;
  438.            
  439.             File fileToUpload = fileChooser.getSelectedFile();
  440.  
  441.             createAmazonS3Bucket();
  442.            
  443.             long startTime = System.nanoTime();
  444.                
  445.             ProgressListener progressListener = new ProgressListener() {
  446.                 public void progressChanged(ProgressEvent progressEvent) {
  447.                    
  448.                                
  449.                     if (upload == null) return;
  450.  
  451.                     progressBar.setValue((int)upload.getProgress().getPercentTransferred());
  452.  
  453.                     switch (progressEvent.getEventCode()) {
  454.                     case ProgressEvent.COMPLETED_EVENT_CODE:
  455.                         progressBar.setValue(100);
  456.                         long endTime = System.nanoTime();
  457.                         uploadDur = (endTime - startTime);  //divide by 1000000 to get millisecond
  458.                         objectList.append("\nSending "+fileToUpload.getName()+" to bucket"+bucketName2+" in "+location+" took "+uploadDur/1000000+"ms");
  459.                         break;
  460.                     case ProgressEvent.FAILED_EVENT_CODE:
  461.                         try {
  462.                             AmazonClientException e = upload.waitForException();
  463.                             JOptionPane.showMessageDialog(frame,
  464.                                     "Unable to upload file to Amazon S3: " + e.getMessage(),
  465.                                     "Error Uploading File", JOptionPane.ERROR_MESSAGE);
  466.                         } catch (InterruptedException e) {}
  467.                         break;
  468.                     }
  469.                 }
  470.             };
  471.  
  472.            
  473.             PutObjectRequest request = new PutObjectRequest(
  474.                     bucketName2,
  475.                     fileToUpload.getName(),
  476.                     fileToUpload).withGeneralProgressListener(progressListener);
  477.             upload = txclient.upload(request);
  478.            
  479.            
  480.            
  481.         }
  482.     }
  483.  
  484.     private void createAmazonS3Bucket() {
  485.         try {
  486.             if (tx.getAmazonS3Client().doesBucketExist(bucketName) == false) {
  487.                 tx.getAmazonS3Client().createBucket(bucketName);
  488.             }
  489.         } catch (AmazonClientException ace) {
  490.             JOptionPane.showMessageDialog(frame, "Unable to create a new Amazon S3 bucket: " + ace.getMessage(),
  491.                     "Error Creating Bucket", JOptionPane.ERROR_MESSAGE);
  492.         }
  493.     }
  494.    
  495.     private JPanel createContentPane() {
  496.        
  497.         leftPanel = new JPanel();
  498.         BoxLayout boxlayoutY = new BoxLayout(leftPanel, BoxLayout.Y_AXIS);
  499.         leftPanel.setLayout(boxlayoutY);
  500.        
  501.         row1Panel = new JPanel();
  502.         BoxLayout boxlayoutX = new BoxLayout(row1Panel, BoxLayout.X_AXIS);
  503.         row1Panel.setLayout(boxlayoutX);
  504.         row1Panel.add(regionLabel);
  505.         row1Panel.add(bucketLabel);
  506.        
  507.         row2Panel = new JPanel();
  508.         BoxLayout boxlayoutX2 = new BoxLayout(row2Panel, BoxLayout.X_AXIS);
  509.         row2Panel.setLayout(boxlayoutX2);
  510.         row2Panel.add(regionsCB);
  511.         row2Panel.add(bucketNameTF);
  512.        
  513.         row3Panel = new JPanel();
  514.         BoxLayout boxlayoutX3 = new BoxLayout(row3Panel, BoxLayout.X_AXIS);
  515.         row3Panel.setLayout(boxlayoutX3);
  516.         row3Panel.add(listBucketsBtn);
  517.         row3Panel.add(createBucketBtn);
  518.         row3Panel.add(clearBucketListTA);
  519.        
  520.         leftPanel.add(row1Panel);
  521.         leftPanel.add(row2Panel);
  522.         leftPanel.add(row3Panel);
  523.         leftPanel.add(bucketList);
  524.         leftPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  525.         leftPanel.setPreferredSize(new Dimension(650, 800));
  526.        
  527.         rightPanel = new JPanel();
  528.         BoxLayout boxlayoutY2 = new BoxLayout(rightPanel, BoxLayout.Y_AXIS);
  529.         rightPanel.setLayout(boxlayoutY2);
  530.        
  531.        
  532.         row21Panel = new JPanel();
  533.         BoxLayout boxlayoutX21 = new BoxLayout(row21Panel, BoxLayout.X_AXIS);
  534.         row21Panel.setLayout(boxlayoutX21);
  535.         row21Panel.add(bucket2NameTF);
  536.         row21Panel.add(listObjectsBtn);
  537.         row21Panel.add(clearObjectListBtn);
  538.        
  539.         row22Panel = new JPanel();
  540.         BoxLayout boxlayoutX22 = new BoxLayout(row22Panel, BoxLayout.X_AXIS);
  541.         row22Panel.setLayout(boxlayoutX22);
  542.         row22Panel.add(uploadBtn);
  543.         row22Panel.add(progressBar);
  544.        
  545.         row23Panel = new JPanel();
  546.         BoxLayout boxlayoutX23 = new BoxLayout(row23Panel, BoxLayout.X_AXIS);
  547.         row23Panel.setLayout(boxlayoutX23);
  548.         row23Panel.add(fileToDownloadTF);
  549.         row23Panel.add(dowloadBtn);
  550.        
  551.         row24Panel = new JPanel();
  552.         BoxLayout boxlayoutX24 = new BoxLayout(row24Panel, BoxLayout.X_AXIS);
  553.         row24Panel.setLayout(boxlayoutX24);
  554.         row24Panel.add(fileToDownloadTF);
  555.         row24Panel.add(dowloadBtn);
  556.        
  557.         row25Panel = new JPanel();
  558.         BoxLayout boxlayoutX25 = new BoxLayout(row25Panel, BoxLayout.X_AXIS);
  559.         row25Panel.setLayout(boxlayoutX25);
  560.         row25Panel.add(fileToDeleteTF);
  561.         row25Panel.add(deleteBtn); 
  562.        
  563.         rightPanel.add(bucket2Label);
  564.         rightPanel.add(row21Panel);
  565.         rightPanel.add(objectList);
  566.         rightPanel.add(row22Panel);
  567.         rightPanel.add(row23Panel);
  568.         rightPanel.add(row24Panel);
  569.         rightPanel.add(row25Panel);
  570.         rightPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  571.         rightPanel.setPreferredSize(new Dimension(650, 800));
  572.    
  573.         mainPanel = new JPanel();
  574.         BoxLayout boxlayoutXmain = new BoxLayout(mainPanel, BoxLayout.X_AXIS);
  575.         mainPanel.setLayout(boxlayoutXmain);
  576.         mainPanel.add(leftPanel);
  577.         mainPanel.add(rightPanel);
  578.  
  579. //      JPanel borderPanel = new JPanel();
  580. //      borderPanel.setLayout(new BorderLayout());
  581. //      borderPanel.add(leftPanel, BorderLayout.EAST);
  582.         mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
  583.         return mainPanel;
  584.     }
  585. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement