java gui swing

32
JAVA GUI Swing http://docs.oracle.com /javase/tutorial/uiswi ng/start/index.html

Upload: gerard

Post on 23-Feb-2016

124 views

Category:

Documents


3 download

DESCRIPTION

JAVA GUI Swing. http://docs.oracle.com/javase/tutorial/uiswing/start/index.html. İlk Gui ( graphical User Interface ). İmports javax. Content Pane. http:// docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html. JComponent Class. - PowerPoint PPT Presentation

TRANSCRIPT

Page 2: JAVA GUI  Swing
Page 3: JAVA GUI  Swing

İlk Gui (graphical User Interface) İmports javax

Page 6: JAVA GUI  Swing

The JComponent API Customizing Component Appearance Setting and Getting Component State Handling Events Painting Components Dealing with the Containment Hierarchy Laying Out Components Getting Size and Position Information Specifying Absolute Size and Position

Page 10: JAVA GUI  Swing

Bileşen Eklemek

Page 11: JAVA GUI  Swing
Page 12: JAVA GUI  Swing
Page 13: JAVA GUI  Swing

CF

Page 14: JAVA GUI  Swing

Rastgele Renkler

Page 15: JAVA GUI  Swing
Page 16: JAVA GUI  Swing

Alternatif ActionListener

Page 17: JAVA GUI  Swing
Page 18: JAVA GUI  Swing
Page 19: JAVA GUI  Swing
Page 20: JAVA GUI  Swing

GridLayout örneği

Page 21: JAVA GUI  Swing

JButton

Page 22: JAVA GUI  Swing

JToggle

Page 23: JAVA GUI  Swing

JRadioButton

Page 24: JAVA GUI  Swing

JRadioButton

Page 25: JAVA GUI  Swing

JComboBox ComboBox.addActionListener( Obje ) Obje implements ActionListener

ActionPerformed (ActionEvent e)

Page 26: JAVA GUI  Swing

JCheckBox

Page 27: JAVA GUI  Swing

Item state Changed

Page 28: JAVA GUI  Swing
Page 29: JAVA GUI  Swing

Java ile Paint işlemleri Metin Boyama

add(new MyPanel());

Page 30: JAVA GUI  Swing

Java ile Boyama MyPanel2class MyPanel extends JPanel {private int squareX = 50; private int squareY = 50; private int squareW = 20; private int squareH = 20; public MyPanel2() { setBorder(BorderFactory.createLineBorder(Color.black)); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { moveSquare(e.getX(),e.getY()); } }); addMouseMotionListener(new MouseAdapter() { public void mouseDragged(MouseEvent e) { moveSquare(e.getX(),e.getY()); } }); } private void moveSquare(int x, int y) { int OFFSET = 1; if ((squareX!=x) || (squareY!=y)) { repaint(squareX,squareY,squareW+OFFSET,squareH+OFFSET);

squareX=x; squareY=y; repaint(squareX,squareY,squareW+OFFSET,squareH+OFFSET); } } public Dimension getPreferredSize() { return new Dimension(250,200); } protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawString("This is my custom Panel!",10,20); g.setColor(Color.RED); g.fillRect(squareX,squareY,squareW,squareH); g.setColor(Color.BLACK); g.drawRect(squareX,squareY,squareW,squareH); } }

Page 31: JAVA GUI  Swing

Paint Methods public void paint(Graphics g)

java.awt.Component.

protected void paintComponent(Graphics g) protected void paintBorder(Graphics g) protected void paintChildren(Graphics g)

Page 32: JAVA GUI  Swing

Key Events .. KeyListener