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
cf2f0519
Commit
cf2f0519
authored
Jan 06, 2020
by
robert.sharp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update temp.java
parent
b8ad60cb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
58 deletions
+68
-58
temp.java
src/main/java/temp.java
+68
-58
No files found.
src/main/java/temp.java
View file @
cf2f0519
...
@@ -30,6 +30,7 @@ public class temp extends javax.swing.JFrame {
...
@@ -30,6 +30,7 @@ public class temp extends javax.swing.JFrame {
static
String
Chosen
=
""
;
static
String
Chosen
=
""
;
static
String
Price
=
""
;
static
String
Price
=
""
;
static
double
quant
=
0
;
static
double
quant
=
0
;
static
int
index
=
0
;
public
temp
()
{
public
temp
()
{
...
@@ -50,9 +51,9 @@ public class temp extends javax.swing.JFrame {
...
@@ -50,9 +51,9 @@ public class temp extends javax.swing.JFrame {
jLabel1
=
new
javax
.
swing
.
JLabel
();
jLabel1
=
new
javax
.
swing
.
JLabel
();
PriceLabel
=
new
javax
.
swing
.
JLabel
();
PriceLabel
=
new
javax
.
swing
.
JLabel
();
jPanel1
=
new
javax
.
swing
.
JPanel
();
jPanel1
=
new
javax
.
swing
.
JPanel
();
Quantity
=
new
javax
.
swing
.
JComboBox
<>();
quantLabel
=
new
javax
.
swing
.
JLabel
();
quantLabel
=
new
javax
.
swing
.
JLabel
();
quantLabelchange
=
new
javax
.
swing
.
JLabel
();
quantLabelchange
=
new
javax
.
swing
.
JLabel
();
quantBox
=
new
javax
.
swing
.
JComboBox
<>();
setDefaultCloseOperation
(
javax
.
swing
.
WindowConstants
.
EXIT_ON_CLOSE
);
setDefaultCloseOperation
(
javax
.
swing
.
WindowConstants
.
EXIT_ON_CLOSE
);
...
@@ -65,13 +66,56 @@ public class temp extends javax.swing.JFrame {
...
@@ -65,13 +66,56 @@ public class temp extends javax.swing.JFrame {
jLabel1
.
setText
(
"Select Item Here:"
);
jLabel1
.
setText
(
"Select Item Here:"
);
PriceLabel
.
setHorizontalAlignment
(
javax
.
swing
.
SwingConstants
.
LEFT
);
PriceLabel
.
setText
(
"Please Select an Item;"
);
PriceLabel
.
setText
(
"Please Select an Item;"
);
quantLabel
.
setText
(
"Input Quanity:"
);
quantLabelchange
.
setText
(
"Selected quantity:"
);
quantBox
.
setModel
(
new
javax
.
swing
.
DefaultComboBoxModel
<>(
new
String
[]
{
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
}));
quantBox
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
quantBoxActionPerformed
(
evt
);
}
});
javax
.
swing
.
GroupLayout
jPanel1Layout
=
new
javax
.
swing
.
GroupLayout
(
jPanel1
);
jPanel1
.
setLayout
(
jPanel1Layout
);
jPanel1Layout
.
setHorizontalGroup
(
jPanel1Layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
jPanel1Layout
.
createSequentialGroup
()
.
addGroup
(
jPanel1Layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
jPanel1Layout
.
createSequentialGroup
()
.
addGap
(
20
,
20
,
20
)
.
addComponent
(
quantLabelchange
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
109
,
Short
.
MAX_VALUE
))
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
jPanel1Layout
.
createSequentialGroup
()
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addGroup
(
jPanel1Layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
,
false
)
.
addComponent
(
quantLabel
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
109
,
Short
.
MAX_VALUE
)
.
addComponent
(
quantBox
,
0
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
))))
.
addContainerGap
())
);
jPanel1Layout
.
setVerticalGroup
(
jPanel1Layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
jPanel1Layout
.
createSequentialGroup
()
.
addContainerGap
(
44
,
Short
.
MAX_VALUE
)
.
addComponent
(
quantLabel
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addComponent
(
quantBox
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
11
,
11
,
11
)
.
addComponent
(
quantLabelchange
)
.
addGap
(
28
,
28
,
28
))
);
javax
.
swing
.
GroupLayout
ItemSelectLayout
=
new
javax
.
swing
.
GroupLayout
(
ItemSelect
);
javax
.
swing
.
GroupLayout
ItemSelectLayout
=
new
javax
.
swing
.
GroupLayout
(
ItemSelect
);
ItemSelect
.
setLayout
(
ItemSelectLayout
);
ItemSelect
.
setLayout
(
ItemSelectLayout
);
ItemSelectLayout
.
setHorizontalGroup
(
ItemSelectLayout
.
setHorizontalGroup
(
ItemSelectLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
ItemSelectLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
ItemSelectLayout
.
createSequentialGroup
()
.
addGroup
(
ItemSelectLayout
.
createSequentialGroup
()
.
addComponent
(
jPanel1
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
0
,
0
,
Short
.
MAX_VALUE
))
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addGroup
(
ItemSelectLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
ItemSelectLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
...
@@ -79,11 +123,10 @@ public class temp extends javax.swing.JFrame {
...
@@ -79,11 +123,10 @@ public class temp extends javax.swing.JFrame {
.
addGap
(
22
,
22
,
22
))
.
addGap
(
22
,
22
,
22
))
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addComponent
(
ItemSelectBox
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
107
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addComponent
(
ItemSelectBox
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
107
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addContainerGap
())
))
.
addContainerGap
())
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
ItemSelectLayout
.
createSequentialGroup
()
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addComponent
(
PriceLabel
)
.
addComponent
(
PriceLabel
)
.
addContainerGap
(
))
.
addContainerGap
())
))
);
);
ItemSelectLayout
.
setVerticalGroup
(
ItemSelectLayout
.
setVerticalGroup
(
ItemSelectLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
ItemSelectLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
...
@@ -94,45 +137,9 @@ public class temp extends javax.swing.JFrame {
...
@@ -94,45 +137,9 @@ public class temp extends javax.swing.JFrame {
.
addComponent
(
ItemSelectBox
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addComponent
(
ItemSelectBox
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addComponent
(
PriceLabel
)
.
addComponent
(
PriceLabel
)
.
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
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addComponent
(
quantLabelchange
)
.
addComponent
(
jPanel1
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
add
Gap
(
23
,
23
,
23
))
.
add
ContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
))
);
);
javax
.
swing
.
GroupLayout
layout
=
new
javax
.
swing
.
GroupLayout
(
getContentPane
());
javax
.
swing
.
GroupLayout
layout
=
new
javax
.
swing
.
GroupLayout
(
getContentPane
());
...
@@ -141,17 +148,13 @@ public class temp extends javax.swing.JFrame {
...
@@ -141,17 +148,13 @@ public class temp extends javax.swing.JFrame {
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGroup
(
layout
.
createSequentialGroup
()
.
addComponent
(
ItemSelect
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
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
)
.
addContainerGap
(
303
,
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
.
setVerticalGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
false
)
.
addComponent
(
ItemSelect
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addComponent
(
jPanel1
,
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addContainerGap
(
30
,
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
();
pack
();
...
@@ -192,18 +195,19 @@ public class temp extends javax.swing.JFrame {
...
@@ -192,18 +195,19 @@ public class temp extends javax.swing.JFrame {
PriceLabel
.
setText
(
"Please selct an Item"
);
PriceLabel
.
setText
(
"Please selct an Item"
);
}
else
{
}
else
{
PriceLabel
.
setText
(
"Price: "
+
Price
);
PriceLabel
.
setText
(
"Price: "
+
Price
);
}
}
//update price label
//update price label
}
//GEN-LAST:event_ItemSelectBoxActionPerformed
}
//GEN-LAST:event_ItemSelectBoxActionPerformed
private
void
QuantityActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_Quantity
ActionPerformed
private
void
quantBoxActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_quantBox
ActionPerformed
// TODO add your handling code here:
// TODO add your handling code here:
//selecting the quanity of items
quant
=
Double
.
parseDouble
(
quantBox
.
getSelectedItem
().
toString
());
quant
=
Double
.
parseDouble
(
Quantity
.
getSelectedItem
().
toString
());
quantLabelchange
.
setText
(
"Selected quantity: "
+
quant
);
quantLabelchange
.
setText
(
"Selected quantity: "
+
quant
);
}
//GEN-LAST:event_
Quantity
ActionPerformed
}
//GEN-LAST:event_
quantBox
ActionPerformed
/**
/**
* @param args the command line arguments
* @param args the command line arguments
...
@@ -239,17 +243,23 @@ public class temp extends javax.swing.JFrame {
...
@@ -239,17 +243,23 @@ public class temp extends javax.swing.JFrame {
});
});
}
}
public
void
removeItem
(){
public
void
findItem
(){
index
=
-
1
;
for
(
int
i
=
0
;
i
<
itemCode
.
length
;
i
++)
{
if
(
itemCode
[
i
].
equals
(
ID
))
{
index
=
i
;
break
;
}
}
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
// Variables declaration - do not modify//GEN-BEGIN:variables
private
javax
.
swing
.
JPanel
ItemSelect
;
private
javax
.
swing
.
JPanel
ItemSelect
;
private
javax
.
swing
.
JComboBox
<
String
>
ItemSelectBox
;
private
javax
.
swing
.
JComboBox
<
String
>
ItemSelectBox
;
private
javax
.
swing
.
JLabel
PriceLabel
;
private
javax
.
swing
.
JLabel
PriceLabel
;
private
javax
.
swing
.
JComboBox
<
String
>
Quantity
;
private
javax
.
swing
.
JLabel
jLabel1
;
private
javax
.
swing
.
JLabel
jLabel1
;
private
javax
.
swing
.
JPanel
jPanel1
;
private
javax
.
swing
.
JPanel
jPanel1
;
private
javax
.
swing
.
JComboBox
<
String
>
quantBox
;
private
javax
.
swing
.
JLabel
quantLabel
;
private
javax
.
swing
.
JLabel
quantLabel
;
private
javax
.
swing
.
JLabel
quantLabelchange
;
private
javax
.
swing
.
JLabel
quantLabelchange
;
// End of variables declaration//GEN-END:variables
// 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