|
1 | 1 | # 20CYS383 Java Programming Lab
|
2 | 2 |   
|
3 | 3 |
|
4 |
| -### JPL-XX |
| 4 | +## Ship Detection |
5 | 5 |
|
6 |
| -#### Team Members |
| 6 | +### Project Description |
7 | 7 |
|
8 | 8 |
|
9 |
| -### Deliverables |
| 9 | +### Module Split-up |
10 | 10 |
|
| 11 | +| Name | Topic | |
| 12 | +|------|-------| |
| 13 | + |
| 14 | +### Code |
| 15 | + |
| 16 | +#### Main-Activity in Java |
| 17 | +``` |
| 18 | +package com.amrita.jpl.cys21090.pract; |
| 19 | +import javax.swing.*; |
| 20 | +import java.awt.*; |
| 21 | +import java.awt.event.ActionEvent; |
| 22 | +import java.awt.event.ActionListener; |
| 23 | +import java.io.File; |
| 24 | +
|
| 25 | +public class di { |
| 26 | + private static JLabel inputImage; |
| 27 | + private static JLabel outputImage; |
| 28 | +
|
| 29 | + public static void main(String[] args) { |
| 30 | + JFrame frame = new JFrame("JAVA_UI_APPLICATION_MULTI_MEDIA"); |
| 31 | + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| 32 | + frame.setSize(800, 600); |
| 33 | + frame.getContentPane().setBackground(Color.LIGHT_GRAY); |
| 34 | +
|
| 35 | + // Creating the topic label |
| 36 | + JLabel topicLabel = new JLabel("SHIP DETECTION USING ARIAL IMAGES "); |
| 37 | + topicLabel.setFont(new Font("Arial", Font.BOLD, 24)); |
| 38 | + topicLabel.setHorizontalAlignment(JLabel.CENTER); |
| 39 | + topicLabel.setBounds(100, 50, 600, 50); |
| 40 | + topicLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
| 41 | + frame.add(topicLabel); |
| 42 | +
|
| 43 | + // Creating the input image column |
| 44 | + JLabel inputLabel = new JLabel("INPUT IMAGE"); |
| 45 | + inputLabel.setBounds(100, 250, 100, 25); |
| 46 | + inputLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
| 47 | + frame.add(inputLabel); |
| 48 | +
|
| 49 | + // Creating the output image column |
| 50 | + JLabel outputLabel = new JLabel("OUTPUT IMAGE"); |
| 51 | + outputLabel.setBounds(500, 250, 100, 25); |
| 52 | + outputLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
| 53 | + frame.add(outputLabel); |
| 54 | +
|
| 55 | + // Creating the input image label |
| 56 | + inputImage = new JLabel(); |
| 57 | + inputImage.setBounds(100, 290, 200, 150); |
| 58 | + inputImage.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
| 59 | + frame.add(inputImage); |
| 60 | +
|
| 61 | + // Creating the output image label |
| 62 | + outputImage = new JLabel(); |
| 63 | + outputImage.setBounds(500, 290, 200, 150); |
| 64 | + outputImage.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
| 65 | + frame.add(outputImage); |
| 66 | +
|
| 67 | + // Creating the footer label |
| 68 | + JLabel footerLabel = new JLabel("Credits: @monish @sudeepv @yuvarajkumar"); |
| 69 | + footerLabel.setHorizontalAlignment(JLabel.CENTER); |
| 70 | + footerLabel.setBounds(0, 500, 900, 25); |
| 71 | + footerLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
| 72 | + frame.add(footerLabel); |
| 73 | +
|
| 74 | + // Creating the file chooser button |
| 75 | + JButton fileChooserButton = new JButton("Upload Image"); |
| 76 | + fileChooserButton.setBounds(350, 400, 100, 25); |
| 77 | + frame.add(fileChooserButton); |
| 78 | +
|
| 79 | + // File chooser action listener |
| 80 | + fileChooserButton.addActionListener(new ActionListener() { |
| 81 | + public void actionPerformed(ActionEvent e) { |
| 82 | + JFileChooser fileChooser = new JFileChooser(); |
| 83 | + int result = fileChooser.showOpenDialog(frame); |
| 84 | + if (result == JFileChooser.APPROVE_OPTION) { |
| 85 | + File selectedFile = fileChooser.getSelectedFile(); |
| 86 | + ImageIcon imageIcon = new ImageIcon(selectedFile.getAbsolutePath()); |
| 87 | + inputImage.setIcon(imageIcon); |
| 88 | + outputImage.setIcon(imageIcon); |
| 89 | + } |
| 90 | + } |
| 91 | + }); |
| 92 | +
|
| 93 | + frame.setLayout(null); |
| 94 | + frame.setVisible(true); |
| 95 | + } |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +#### Screenshots |
0 commit comments