Java gui swing
Download
1 / 32

JAVA GUI Swing - PowerPoint PPT Presentation


  • 181 Views
  • Uploaded on

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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' JAVA GUI Swing' - gerard


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Java gui swing

JAVA GUI Swing

http://docs.oracle.com/javase/tutorial/uiswing/start/index.html


Lk gui graphical user interface
İlk Gui (graphical User Interface)

  • İmportsjavax


Content pane
Content Pane

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


Jcomponent class
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


The jcomponent api
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


Using text components
Using TextComponents

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


Text component api
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


Visual java components
Visual Java Components

  • http://docs.oracle.com/javase/tutorial/ui/features/compWin.html



CF



Alternatif actionlistener
Alternatif ActionListener


Gridlayout rne i
GridLayout örneği






Jcombobox
JComboBox

  • ComboBox.addActionListener( Obje )

  • Obje implementsActionListener

    • ActionPerformed (ActionEvent e)



Item state changed
ItemstateChanged


Java ile paint i lemleri
Java ile Paint işlemleri

  • Metin Boyama

  • add(newMyPanel());


Java ile boyama mypanel2
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);

}

}


Paint methods
Paint Methods

  • publicvoidpaint(Graphics g) java.awt.Component.

  • protectedvoidpaintComponent(Graphics g)

  • protectedvoidpaintBorder(Graphics g)

  • protectedvoidpaintChildren(Graphics g)


Key events keylistener
KeyEvents .. KeyListener


ad