The document outlines the steps to create a first program in Java using Eclipse, including creating classes called "PruebaAlbum" and "Album", declaring attributes and generating getter and setter methods in the "Album" class, constructing the "Album" class, instantiating "Album" objects in "PruebaAlbum", developing a "PRINT Album" method, and calling that method on the instances to display their values.
This winter runaway campaign is a digital strategy that ROXY can apply to raise brand awareness and build brand image. The content of this campaign, the eight destinations, will be the core to attract site traffic. Social media outlets and Google Adwords will also help push the content to reach more customers. The shareworthy content and the promotion on college girls are potential to go viral online. Through landing pages and sign-up database, ROXY can also do CRM better. Finally, we are confident to see sales return on the investment of the campaign.
This winter runaway campaign is a digital strategy that ROXY can apply to raise brand awareness and build brand image. The content of this campaign, the eight destinations, will be the core to attract site traffic. Social media outlets and Google Adwords will also help push the content to reach more customers. The shareworthy content and the promotion on college girls are potential to go viral online. Through landing pages and sign-up database, ROXY can also do CRM better. Finally, we are confident to see sales return on the investment of the campaign.
Java Program Photo Viewer1. Write an app called viewer that will .pdfbhim1213
Java Program: Photo Viewer
1. Write an app called viewer that will have a Label at the top saying \"My Viewer\" (or
something like that)
2. Will have JButtons at the bottom that will do Next, Previous, and Quit
3. Have the whole middle be a JLabel in which you will display Images stored in a directory.
4. The directory can be named Resource.
5. When you run the program (java viewer) it will read all the names in the Resource Directory.
Then, when you click Next or Previous it will display an Image.
6. Note: you will need to find a java method that exists for reading a whole directory of
filenames. You can store all those names in a String Array when run the program.
7. You will use a counter or index that is an int an when you click Next it will increment the
counter until it reach some maximum value and then you will set it to 0. Previous will decrement
the counter until it goes negative and then it will set the counter to the Maximum index ( which
is how many filenames you have in the Image names array)
8. Submit the program viewer.java I should be able to use it with my own Resource directory.
Solution
Please refer this code for your application :
--------------------------------------------------------------------------------------------------------------------
--------------
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
public class ImageViewer extends javax.swing.JFrame {
public ImageViewer() {
initComponents();
listFiles(Path); //Lists all the files in the directory on window opening
setLabelIcon(Path,filenames[position]); //sets the label to display the first
//image in the directory on window opening.
PreviousButton.setEnabled(false);
}
/**
*Initialize components
*/
private void initComponents() {
setTitle(\"Image Viewer\");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new java.awt.BorderLayout());// The layout is BorderLayout
//setBorder(javax.swing.BorderFactory.createEtchedBorder());
setBackground(java.awt.Color.GRAY);
picLabel = new javax.swing.JLabel(); //Create the Label to display the picture
picLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
picLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
PreviousButton = new javax.swing.JButton();
PreviousButton.setText(\"Previous\");
PreviousButton.setIconTextGap(10); //Distance between the icon and text is 10
PreviousButton.addActionListener(new java.awt.event.ActionListener() { //Register an
actionListener for the PreviousButton
public void actionPerformed(java.awt.event.ActionEvent evt) {
PreviousButtonActionPerformed(evt);
}
});
NextButton = new javax.swing.JButton();
NextButton.setPreferredSize(PreviousButton.getPreferredSize());
NextButton.setText(\"Next\");
NextButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
NextButton.setIconTextGap(10); //Distance between the icon and text is 10
NextButton.addActionListener(new java.awt.event.ActionL.
Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docxalfred4lewis58146
Page 8 of 8
3.Tutorial: Get Started with Eclipse in the Computer Lab[footnoteRef:1] [1: This tutorial is modified from
Eclipse Tutorial – Getting Started by Dr. John Dean (http://captain.park.edu/jdean/tutorials/eclipseDnldTutorial.doc ) and
How To Install Eclipse and Get Started with Java Programming from https://www3.ntu.edu.sg/home/ehchua/programming/howto/EclipseJava_HowTo.html (retrieved on 8/8/2015)]
(Last updated: 8/16/2015)
In this tutorial you will practice using Eclipse to build Java programs in computer labs (such as SC113) on campus. We will practice:
A. Get familiar with the Eclipse IDE
B. Set up the coding style preference (such as two-space indent and soft tab) used in this course
C. Build and run the famous Hello World! Project
D. Create a project by copying from an existing project
E. Terminate a running program
* * *
Eclipse is an Integrated Development Environment (IDE) that allows you to enter, compile, and run programs. The programs can be written in one of many different languages, such of Java, C/C++, and PHP. Computer labs on campus already has Eclipse ready for Java development.
The screenshot below shows the default layout of Eclipse. Take a look now and refer back to this screenshot as to where things are while you work through this tutorial.
1. Menu
2. Toolbar
3. Package Explorer: display all your projects and files. Yours will be empty at this point.
4. Editor
5. Outline view: displays data and method members of the currently selected Java class
6. Console panel
If you accidentally closed or moved one of the panels above, you can always restore this default layout by:
· First choose “Window” menu => “Open Perspective” => “Other…” and select “Java (default)” in the “Open Perspective” dialog. In Eclipse a perspective defines the initial set and layout of views in the Workbench window.
· Then choose “Window” menu => “Reset Perspectives” and click “Yes”
* * *
Tip: when taking screenshots of the running result for your homework report, you may temporarily make the console panel section bigger so it shows the complete running result. Afterwards follow the steps above to restore the layout.
* * *
SAVING FILES:
· Naturally, you are required to save your program files. In the lab, you are required to save your files on a USB flash drive storage device. If you're working at home, you may save your files on your computer's hard disk, but you're still required to have a flash drive so that you can transport your files to and from school. If you're at the school's lab, do not use the hard disks ever!
ECLIPSE TUTORIAL:
If you forget how to do something in Eclipse, it is up to you to carefully reread this Eclipse tutorial and figure out how to do things. To reduce the number of rereads, go through this tutorial slowly and try to remember what you're doing.
This tutorial uses x: to refer to the drive that you're saving your work on. In the lab, x: should be replaced by the USB drive (assuming that yo.
Introduction and BackgroundIn recent lectures we discussed usi.pdfarpitaeron555
Introduction and Background
In recent lectures we discussed using arrays, classes and interfaces (see newly added course
notes if you want to read ahead about interfaces – we will cover them this week in lecture). In
this lab you will utilize all of these topics to build a simple yet useful new class. Consider the
following interface describing the methods for a simple double ended queue (or deque):
public interface SimpleDeque
{
public void addFront(Object X); // Add Object X at front of list
public void addRear(Object X); // Add Object X at rear of list
// If array is full, add methods should do nothing
public Object removeFront(); // Remove and return Object X from
// front of list
public Object removeRear(); // Remove and return Object X from
// rear of list
// If array is empty, remove methods should return null
public boolean isEmpty(); // Return true if the list is empty
// Return false otherwise
}
A queue has the behavior such that items are added at the rear and removed from the front,
thereby giving a First In First Out (FIFO) access to the items added and subsequently removed
from the list. No other manipulations of the data are permitted (for example, we cannot add or
remove anywhere in the middle). Looking at it \"in reverse\", we could add new items at the
front of the queue and remove them from the rear. This is still providing FIFO access, but just
from a different point of view. Now consider both adding and removing items at the rear of the
list (without ever accessing the front). This is called stack access and gives us Last In First Out
(LIFO) access to the items (the data is removed in reverse order). The same behavior occurs if
we both add and remove at the front without ever accessing the rear of the list.
The simple deque above is expressed as an interface rather than a class, because we are not
describing the data or how it is represented -- we are simply describing its access behavior.
However, to actually build a working deque, we need a class that implements the interface
above. For example:
public class MyDeque implements SimpleDeque
{
Object [] theData;
int numItems;
public MyDeque(int maxItems)
{
theData = new Object[maxItems];
numItems = 0;
}
// Implementation of the five methods of SimpleDeque, plus
// perhaps other methods as well
}
Note that the implementation above uses an array of Object to store the items in the deque. Since
Object is the base class to all other Java classes, an array of Object can thus be used to store any
Java class types (we can even store primitive values if we utilize their wrapper classes). Also
note that nothing in the SimpleDeque interface requires an array to be used to store the data. You
will see in your CS 0445 course that a linked list may in fact be a better implementation than an
array in this case. However, for this implementation we will use an array because it is simple and
easy to understand.
Another important thing to notice about the partial implementation above is tha.
Java Program Photo Viewer1. Write an app called viewer that will .pdfbhim1213
Java Program: Photo Viewer
1. Write an app called viewer that will have a Label at the top saying \"My Viewer\" (or
something like that)
2. Will have JButtons at the bottom that will do Next, Previous, and Quit
3. Have the whole middle be a JLabel in which you will display Images stored in a directory.
4. The directory can be named Resource.
5. When you run the program (java viewer) it will read all the names in the Resource Directory.
Then, when you click Next or Previous it will display an Image.
6. Note: you will need to find a java method that exists for reading a whole directory of
filenames. You can store all those names in a String Array when run the program.
7. You will use a counter or index that is an int an when you click Next it will increment the
counter until it reach some maximum value and then you will set it to 0. Previous will decrement
the counter until it goes negative and then it will set the counter to the Maximum index ( which
is how many filenames you have in the Image names array)
8. Submit the program viewer.java I should be able to use it with my own Resource directory.
Solution
Please refer this code for your application :
--------------------------------------------------------------------------------------------------------------------
--------------
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
public class ImageViewer extends javax.swing.JFrame {
public ImageViewer() {
initComponents();
listFiles(Path); //Lists all the files in the directory on window opening
setLabelIcon(Path,filenames[position]); //sets the label to display the first
//image in the directory on window opening.
PreviousButton.setEnabled(false);
}
/**
*Initialize components
*/
private void initComponents() {
setTitle(\"Image Viewer\");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new java.awt.BorderLayout());// The layout is BorderLayout
//setBorder(javax.swing.BorderFactory.createEtchedBorder());
setBackground(java.awt.Color.GRAY);
picLabel = new javax.swing.JLabel(); //Create the Label to display the picture
picLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
picLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
PreviousButton = new javax.swing.JButton();
PreviousButton.setText(\"Previous\");
PreviousButton.setIconTextGap(10); //Distance between the icon and text is 10
PreviousButton.addActionListener(new java.awt.event.ActionListener() { //Register an
actionListener for the PreviousButton
public void actionPerformed(java.awt.event.ActionEvent evt) {
PreviousButtonActionPerformed(evt);
}
});
NextButton = new javax.swing.JButton();
NextButton.setPreferredSize(PreviousButton.getPreferredSize());
NextButton.setText(\"Next\");
NextButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
NextButton.setIconTextGap(10); //Distance between the icon and text is 10
NextButton.addActionListener(new java.awt.event.ActionL.
Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docxalfred4lewis58146
Page 8 of 8
3.Tutorial: Get Started with Eclipse in the Computer Lab[footnoteRef:1] [1: This tutorial is modified from
Eclipse Tutorial – Getting Started by Dr. John Dean (http://captain.park.edu/jdean/tutorials/eclipseDnldTutorial.doc ) and
How To Install Eclipse and Get Started with Java Programming from https://www3.ntu.edu.sg/home/ehchua/programming/howto/EclipseJava_HowTo.html (retrieved on 8/8/2015)]
(Last updated: 8/16/2015)
In this tutorial you will practice using Eclipse to build Java programs in computer labs (such as SC113) on campus. We will practice:
A. Get familiar with the Eclipse IDE
B. Set up the coding style preference (such as two-space indent and soft tab) used in this course
C. Build and run the famous Hello World! Project
D. Create a project by copying from an existing project
E. Terminate a running program
* * *
Eclipse is an Integrated Development Environment (IDE) that allows you to enter, compile, and run programs. The programs can be written in one of many different languages, such of Java, C/C++, and PHP. Computer labs on campus already has Eclipse ready for Java development.
The screenshot below shows the default layout of Eclipse. Take a look now and refer back to this screenshot as to where things are while you work through this tutorial.
1. Menu
2. Toolbar
3. Package Explorer: display all your projects and files. Yours will be empty at this point.
4. Editor
5. Outline view: displays data and method members of the currently selected Java class
6. Console panel
If you accidentally closed or moved one of the panels above, you can always restore this default layout by:
· First choose “Window” menu => “Open Perspective” => “Other…” and select “Java (default)” in the “Open Perspective” dialog. In Eclipse a perspective defines the initial set and layout of views in the Workbench window.
· Then choose “Window” menu => “Reset Perspectives” and click “Yes”
* * *
Tip: when taking screenshots of the running result for your homework report, you may temporarily make the console panel section bigger so it shows the complete running result. Afterwards follow the steps above to restore the layout.
* * *
SAVING FILES:
· Naturally, you are required to save your program files. In the lab, you are required to save your files on a USB flash drive storage device. If you're working at home, you may save your files on your computer's hard disk, but you're still required to have a flash drive so that you can transport your files to and from school. If you're at the school's lab, do not use the hard disks ever!
ECLIPSE TUTORIAL:
If you forget how to do something in Eclipse, it is up to you to carefully reread this Eclipse tutorial and figure out how to do things. To reduce the number of rereads, go through this tutorial slowly and try to remember what you're doing.
This tutorial uses x: to refer to the drive that you're saving your work on. In the lab, x: should be replaced by the USB drive (assuming that yo.
Introduction and BackgroundIn recent lectures we discussed usi.pdfarpitaeron555
Introduction and Background
In recent lectures we discussed using arrays, classes and interfaces (see newly added course
notes if you want to read ahead about interfaces – we will cover them this week in lecture). In
this lab you will utilize all of these topics to build a simple yet useful new class. Consider the
following interface describing the methods for a simple double ended queue (or deque):
public interface SimpleDeque
{
public void addFront(Object X); // Add Object X at front of list
public void addRear(Object X); // Add Object X at rear of list
// If array is full, add methods should do nothing
public Object removeFront(); // Remove and return Object X from
// front of list
public Object removeRear(); // Remove and return Object X from
// rear of list
// If array is empty, remove methods should return null
public boolean isEmpty(); // Return true if the list is empty
// Return false otherwise
}
A queue has the behavior such that items are added at the rear and removed from the front,
thereby giving a First In First Out (FIFO) access to the items added and subsequently removed
from the list. No other manipulations of the data are permitted (for example, we cannot add or
remove anywhere in the middle). Looking at it \"in reverse\", we could add new items at the
front of the queue and remove them from the rear. This is still providing FIFO access, but just
from a different point of view. Now consider both adding and removing items at the rear of the
list (without ever accessing the front). This is called stack access and gives us Last In First Out
(LIFO) access to the items (the data is removed in reverse order). The same behavior occurs if
we both add and remove at the front without ever accessing the rear of the list.
The simple deque above is expressed as an interface rather than a class, because we are not
describing the data or how it is represented -- we are simply describing its access behavior.
However, to actually build a working deque, we need a class that implements the interface
above. For example:
public class MyDeque implements SimpleDeque
{
Object [] theData;
int numItems;
public MyDeque(int maxItems)
{
theData = new Object[maxItems];
numItems = 0;
}
// Implementation of the five methods of SimpleDeque, plus
// perhaps other methods as well
}
Note that the implementation above uses an array of Object to store the items in the deque. Since
Object is the base class to all other Java classes, an array of Object can thus be used to store any
Java class types (we can even store primitive values if we utilize their wrapper classes). Also
note that nothing in the SimpleDeque interface requires an array to be used to store the data. You
will see in your CS 0445 course that a linked list may in fact be a better implementation than an
array in this case. However, for this implementation we will use an array because it is simple and
easy to understand.
Another important thing to notice about the partial implementation above is tha.
2. Step by step creation of the first program in Java using
Eclipse
1. Run the sequence of actions detailed in the chart.
2. Run after the sequence of actions detailed in the chart.
Kenia Álava
3. 3. Insert a class called "PruebaAlbum" as follows.
4. Now insert a class called "Album", in the same way as the previous step
5. The result after the above steps is a structure as follows.
6. Declare the following attributes within the class "Album"
Kenia Álava
4. 7. Then set the SET and GET methods (methods are inserting, modifying and extracting the
values that variables may have happened before, "automatically generated"), this
operation is called to create getters and setters.
8. Notice how you generated the following code block without you had to write
9. Define the following constructor.
The constructor is a method that must have the same name as the class and is used to
initialize the attributes of an object, usually receives values that have happened, a quick
way is to develop a method using getters and setters from the previous step.
Kenia Álava
5. 10. Now we instantiate an object of class "Album" in class
"PruebaAlbum", this instance or reference to create should be made in the main.
See how you created two instances, and the way in which you can send arguments.
11. In the previous step we created two instances, how can we show these values on
screen?
We must develop a new method in the "Album", will be called "PRINT Album"
12. Then call the method created from the two instances declared in step 10.
13. And finally see the execution, after clicking on the button should appear something as
follows:
Kenia Álava