Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VendingMachine_Robert_Sharp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
robert.sharp
VendingMachine_Robert_Sharp
Commits
5e42f4ed
Commit
5e42f4ed
authored
Jan 06, 2020
by
robert.sharp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update temp.java
parent
47f50a14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
20 deletions
+83
-20
temp.java
src/main/java/temp.java
+83
-20
No files found.
src/main/java/temp.java
View file @
5e42f4ed
...
...
@@ -23,12 +23,13 @@ public class temp extends javax.swing.JFrame {
//the code of the items
static
String
itemName
[]={
"Chocolate"
,
"Water"
,
"Drink"
,
"Snack"
,
"Sweet"
};
//the names of the items
static
double
basket
[]={
0
,
0
,
0
,
0
,
0
};
//setting the default values
static
String
ID
=
""
;
static
String
Chosen
=
""
;
static
String
Price
=
""
;
static
double
quant
=
0
;
public
temp
()
{
...
...
@@ -48,6 +49,10 @@ public class temp extends javax.swing.JFrame {
ItemSelectBox
=
new
javax
.
swing
.
JComboBox
<>();
jLabel1
=
new
javax
.
swing
.
JLabel
();
PriceLabel
=
new
javax
.
swing
.
JLabel
();
jPanel1
=
new
javax
.
swing
.
JPanel
();
Quantity
=
new
javax
.
swing
.
JComboBox
<>();
quantLabel
=
new
javax
.
swing
.
JLabel
();
quantLabelchange
=
new
javax
.
swing
.
JLabel
();
setDefaultCloseOperation
(
javax
.
swing
.
WindowConstants
.
EXIT_ON_CLOSE
);
...
...
@@ -60,25 +65,25 @@ public class temp extends javax.swing.JFrame {
jLabel1
.
setText
(
"Select Item Here:"
);
PriceLabel
.
setText
(
"Please Select an Item;"
);
javax
.
swing
.
GroupLayout
ItemSelectLayout
=
new
javax
.
swing
.
GroupLayout
(
ItemSelect
);
ItemSelect
.
setLayout
(
ItemSelectLayout
);
ItemSelectLayout
.
setHorizontalGroup
(
ItemSelectLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
ItemSelectLayout
.
createSequentialGroup
()
.
addContainerGap
()
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addGroup
(
ItemSelectLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
ItemSelectLayout
.
createSequentialGroup
()
.
addGap
(
0
,
0
,
Short
.
MAX_VALUE
)
.
addGroup
(
ItemSelectLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addComponent
(
jLabel1
)
.
addGap
(
22
,
22
,
22
))
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addComponent
(
ItemSelectBox
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
107
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addContainerGap
())))
.
addGroup
(
ItemSelectLayout
.
createSequentialGroup
()
.
addComponent
(
PriceLabel
)
.
addGap
(
0
,
0
,
Short
.
MAX_VALUE
))))
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addComponent
(
jLabel1
)
.
addGap
(
22
,
22
,
22
))
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addComponent
(
ItemSelectBox
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
107
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addContainerGap
())))
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addComponent
(
PriceLabel
)
.
addContainerGap
())
);
ItemSelectLayout
.
setVerticalGroup
(
ItemSelectLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
...
...
@@ -89,22 +94,64 @@ public class temp extends javax.swing.JFrame {
.
addComponent
(
ItemSelectBox
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addComponent
(
PriceLabel
)
.
addContainerGap
(
30
,
Short
.
MAX_VALUE
))
.
addContainerGap
(
26
,
Short
.
MAX_VALUE
))
);
Quantity
.
setModel
(
new
javax
.
swing
.
DefaultComboBoxModel
<>(
new
String
[]
{
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
}));
Quantity
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
QuantityActionPerformed
(
evt
);
}
});
quantLabel
.
setText
(
"Select Quanity:"
);
quantLabelchange
.
setText
(
"Selected quantity:"
);
javax
.
swing
.
GroupLayout
jPanel1Layout
=
new
javax
.
swing
.
GroupLayout
(
jPanel1
);
jPanel1
.
setLayout
(
jPanel1Layout
);
jPanel1Layout
.
setHorizontalGroup
(
jPanel1Layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
jPanel1Layout
.
createSequentialGroup
()
.
addContainerGap
()
.
addGroup
(
jPanel1Layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addComponent
(
quantLabelchange
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addGroup
(
jPanel1Layout
.
createSequentialGroup
()
.
addGroup
(
jPanel1Layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addComponent
(
Quantity
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
108
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addComponent
(
quantLabel
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
109
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
))
.
addGap
(
0
,
30
,
Short
.
MAX_VALUE
)))
.
addContainerGap
())
);
jPanel1Layout
.
setVerticalGroup
(
jPanel1Layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
jPanel1Layout
.
createSequentialGroup
()
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addComponent
(
quantLabel
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
RELATED
)
.
addComponent
(
Quantity
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addComponent
(
quantLabelchange
)
.
addGap
(
23
,
23
,
23
))
);
javax
.
swing
.
GroupLayout
layout
=
new
javax
.
swing
.
GroupLayout
(
getContentPane
());
getContentPane
().
setLayout
(
layout
);
layout
.
setHorizontalGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
layout
.
createSequentialGroup
()
.
addGap
(
0
,
279
,
Short
.
MAX_VALUE
)
.
addComponent
(
ItemSelect
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
))
.
addGroup
(
layout
.
createSequentialGroup
()
.
addComponent
(
ItemSelect
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
RELATED
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addComponent
(
jPanel1
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
150
,
150
,
150
))
);
layout
.
setVerticalGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addComponent
(
ItemSelect
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
0
,
168
,
Short
.
MAX_VALUE
))
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
false
)
.
addComponent
(
jPanel1
,
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addComponent
(
ItemSelect
,
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
))
.
addContainerGap
(
168
,
Short
.
MAX_VALUE
))
);
pack
();
...
...
@@ -150,6 +197,14 @@ public class temp extends javax.swing.JFrame {
//update price label
}
//GEN-LAST:event_ItemSelectBoxActionPerformed
private
void
QuantityActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_QuantityActionPerformed
// TODO add your handling code here:
//selecting the quanity of items
quant
=
Double
.
parseDouble
(
Quantity
.
getSelectedItem
().
toString
());
quantLabelchange
.
setText
(
"Selected quantity: "
+
quant
);
}
//GEN-LAST:event_QuantityActionPerformed
/**
* @param args the command line arguments
*/
...
...
@@ -183,12 +238,20 @@ public class temp extends javax.swing.JFrame {
}
});
}
public
void
removeItem
(){
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private
javax
.
swing
.
JPanel
ItemSelect
;
private
javax
.
swing
.
JComboBox
<
String
>
ItemSelectBox
;
private
javax
.
swing
.
JLabel
PriceLabel
;
private
javax
.
swing
.
JComboBox
<
String
>
Quantity
;
private
javax
.
swing
.
JLabel
jLabel1
;
private
javax
.
swing
.
JPanel
jPanel1
;
private
javax
.
swing
.
JLabel
quantLabel
;
private
javax
.
swing
.
JLabel
quantLabelchange
;
// End of variables declaration//GEN-END:variables
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment