Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kurs_java_alx_20240321
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Patryk Czarnik
kurs_java_alx_20240321
Commits
f928dec0
Commit
f928dec0
authored
Apr 12, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kalkualtor - wiele działań
parent
d852f3a8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
OknoKalkulatora.form
src/swing/kalkulator/OknoKalkulatora.form
+4
-1
OknoKalkulatora.java
src/swing/kalkulator/OknoKalkulatora.java
+22
-1
No files found.
src/swing/kalkulator/OknoKalkulatora.form
View file @
f928dec0
...
...
@@ -57,7 +57,7 @@
<Component
id=
"jButton1"
pref=
"72"
max=
"32767"
attributes=
"0"
/>
<Component
id=
"jTextField3"
max=
"32767"
attributes=
"0"
/>
</Group>
<EmptySpace
max=
"32767"
attributes=
"0"
/>
<EmptySpace
pref=
"14"
max=
"32767"
attributes=
"0"
/>
</Group>
</Group>
</DimensionLayout>
...
...
@@ -107,6 +107,9 @@
</Property>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Oblicz"
/>
</Properties>
<Events>
<EventHandler
event=
"actionPerformed"
listener=
"java.awt.event.ActionListener"
parameters=
"java.awt.event.ActionEvent"
handler=
"jButton1ActionPerformed"
/>
</Events>
</Component>
<Component
class=
"javax.swing.JTextField"
name=
"jTextField3"
>
<Properties>
...
...
src/swing/kalkulator/OknoKalkulatora.java
View file @
f928dec0
...
...
@@ -43,6 +43,11 @@ public class OknoKalkulatora extends javax.swing.JFrame {
jButton1
.
setFont
(
new
java
.
awt
.
Font
(
"Arial"
,
0
,
32
));
// NOI18N
jButton1
.
setText
(
"Oblicz"
);
jButton1
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
jButton1ActionPerformed
(
evt
);
}
});
jTextField3
.
setFont
(
new
java
.
awt
.
Font
(
"Arial"
,
0
,
32
));
// NOI18N
jTextField3
.
setHorizontalAlignment
(
javax
.
swing
.
JTextField
.
RIGHT
);
...
...
@@ -78,7 +83,7 @@ public class OknoKalkulatora extends javax.swing.JFrame {
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
,
false
)
.
addComponent
(
jButton1
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
72
,
Short
.
MAX_VALUE
)
.
addComponent
(
jTextField3
))
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
))
.
addContainerGap
(
14
,
Short
.
MAX_VALUE
))
);
pack
();
...
...
@@ -88,6 +93,22 @@ public class OknoKalkulatora extends javax.swing.JFrame {
// TODO add your handling code here:
}
//GEN-LAST:event_jComboBox1ActionPerformed
private
void
jButton1ActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_jButton1ActionPerformed
long
liczba1
=
Long
.
parseLong
(
jTextField1
.
getText
());
long
liczba2
=
Long
.
parseLong
(
jTextField2
.
getText
());
String
operacja
=
(
String
)
jComboBox1
.
getSelectedItem
();
// String operacja = jComboBox1.getItemAt(jComboBox1.getSelectedIndex());
long
wynik
=
switch
(
operacja
)
{
case
"+"
->
liczba1
+
liczba2
;
case
"-"
->
liczba1
-
liczba2
;
case
"*"
->
liczba1
*
liczba2
;
case
"/"
->
liczba1
/
liczba2
;
default
->
0
;
};
jTextField3
.
setText
(
String
.
valueOf
(
wynik
));
}
//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
*/
...
...
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