Commit e41b5e1c by Patryk Czarnik

Form w IntelliJ

parent b54a9964
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="swing.proby_gui.Proba1">
<grid id="27dc6" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="734" height="139"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="9b92a" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Podaj swoje imię"/>
</properties>
</component>
<component id="defba" class="javax.swing.JTextField" binding="textField1" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="7d509" class="javax.swing.JButton" binding="OKButton" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
<component id="b39c5" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
</children>
</grid>
</form>
package swing.proby_gui;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Proba1 {
private JTextField textField1;
private JButton OKButton;
public Proba1() {
OKButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String imie = textField1.getText();
}
});
}
}
...@@ -51,9 +51,11 @@ public class Rysowanie2D { ...@@ -51,9 +51,11 @@ public class Rysowanie2D {
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
if(g instanceof Graphics2D) { // Nowa możliwość Javy: rzutowanie bezpośrednio w instanceof
Graphics2D g2 = (Graphics2D)g; // ("pattern matching")
if(g instanceof Graphics2D g2) {
//Graphics2D g2 = (Graphics2D)g;
AffineTransform pustyTrans = g2.getTransform(); AffineTransform pustyTrans = g2.getTransform();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment