1 / 32

JAVA GUI Swing

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.

gerard
Télécharger la présentation

JAVA GUI Swing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JAVA GUI Swing http://docs.oracle.com/javase/tutorial/uiswing/start/index.html

  2. İlk Gui (graphical User Interface) • İmportsjavax

  3. Content Pane • http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html

  4. JComponentClass • all Swing components whose names begin with "J" descend from the JComponentclass • JPanel, JScrollPane, JButton, andJTableallinheritfromJcomponent • JComponentFeatures • Tool tips • Painting and borders • Application-wide pluggable look and feel • Custom properties • Support for layout • Support for accessibility • Support for drag and drop • Double buffering • Key bindings

  5. TheJComponentAPI • 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

  6. Using TextComponents • http://docs.oracle.com/javase/tutorial/uiswing/examples/components/index.html#TextSamplerDemo

  7. Text Component API • Setting Attributes • Manipulating the Selection • Converting Positions Between the Model and the View • Text Editing Commands • Classes and Interfaces That Represent Documents • Working With Documents • Manipulating Carets and Selection Highlighters • Reading and Writing Text

  8. Visual Java Components • http://docs.oracle.com/javase/tutorial/ui/features/compWin.html

  9. Bileşen Eklemek

  10. CF

  11. Rastgele Renkler

  12. Alternatif ActionListener

  13. GridLayout örneği

  14. JButton

  15. JToggle

  16. JRadioButton

  17. JRadioButton

  18. JComboBox • ComboBox.addActionListener( Obje ) • Obje implementsActionListener • ActionPerformed (ActionEvent e)

  19. JCheckBox

  20. ItemstateChanged

  21. Java ile Paint işlemleri • Metin Boyama • add(newMyPanel());

  22. Java ile Boyama MyPanel2 class MyPanel extends JPanel{ private intsquareX = 50; private intsquareY = 50; private intsquareW = 20; private intsquareH = 20; publicMyPanel2() { setBorder(BorderFactory.createLineBorder(Color.black)); addMouseListener(newMouseAdapter() { publicvoidmousePressed(MouseEvent e) { moveSquare(e.getX(),e.getY()); } }); addMouseMotionListener(newMouseAdapter() { publicvoidmouseDragged(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); } } publicDimensiongetPreferredSize() { returnnewDimension(250,200); } protectedvoidpaintComponent(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); } }

  23. Paint Methods • publicvoidpaint(Graphics g) java.awt.Component. • protectedvoidpaintComponent(Graphics g) • protectedvoidpaintBorder(Graphics g) • protectedvoidpaintChildren(Graphics g)

  24. KeyEvents .. KeyListener

More Related