An warware: java sami girman allo

sami girman allo A cikin duniyar haษ“aka software, samun girman allo na na'ura muhimmin al'amari ne, ba kawai don daidaita mu'amalar masu amfani ba har ma don ฦ™irฦ™irar aikace-aikacen amsawa da daidaitawa. ฦŠaya daga cikin shahararrun yaren shirye-shiryen da ke ba masu haษ“aka damar cimma wannan shine Java. A cikin wannan labarin, za mu bincika yadda ake samun girman allo a Java, samar da bayanin mataki-mataki na lambar, da kuma tattauna ษ—akunan karatu da ayyuka masu alaฦ™a da ke cikin wannan tsari.

Samun Girman allo ta amfani da Java

Java yana ba da aji mai suna Toolkit wanda nasa ne java.awt kunshin. Wannan ajin yana ba da hanyoyi da yawa waษ—anda ke taimakawa masu haษ“aka aiki tare da aikace-aikacen GUI. Daya daga cikin wadannan hanyoyin shine GetScreenSize(), wanda ke mayar da girman allo a matsayin misali na girma aji.

import java.awt.Dimension;
import java.awt.Toolkit;

public class Main {

  public static void main(String[] args) {
    // Obtain the screen size
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    // Get the width and height
    int width = screenSize.width;
    int height = screenSize.height;

    System.out.println("Screen Width: " + width);
    System.out.println("Screen Height: " + height);
  }
}

Bayanin mataki-mataki na Code

Lambar da ke sama tana nuna yadda ake samun girman allo ta amfani da Java. Bari mu karya shi mataki-mataki:

1. Na farko, muna shigo da darussan da ake bukata daga java.awt kunshin - girma da kuma Toolkit.

2. A cikin babban hanya, muna kira da samunDefaultToolkit() Hanyar Toolkit aji don samun misali na tsoffin kayan aiki, wanda ke ba da dama ga hanyoyin amfani daban-daban.

3. Sa'an nan, mu kira da GetScreenSize() hanya akan misalin kayan aiki, wanda ke dawo da a girma abu mai wakiltar girman allo. An adana nisa da tsayin allo azaman kaddarorin girma abu.

4. A ฦ™arshe, muna dawo da nisa da tsawo daga girma abu kuma buga ฦ™imar zuwa na'ura wasan bidiyo.

Toolkit Class a cikin Java.awt Kunshin

The Toolkit class a cikin java.awt kunshin wani muhimmin abu ne na Kayan aikin Tagar Abstract (AWT) a Java. Wannan ajin yana ba da hanyoyin yin hulษ—a tare da tsarin taga na asali. Baya ga samun girman allo, da Toolkit aji kuma yana ba da hanyoyi don:

  • Samun hoto
  • ฦ˜irฦ™irar siginar al'ada
  • Samun ฦ™udurin allo
  • ฦ˜ara mai magana

Waษ—annan hanyoyin suna ba masu haษ“akawa damar ฦ™irฦ™irar mafi kyawun mu'amalar mai amfani waษ—anda ke gauraya da tsarin aiki ba tare da matsala ba.

Class Dimension in Java.awt Package

The girma aji wani muhimmin bangare ne na AWT. Yana ษ—aukar faษ—i da tsayin sashi a cikin abu ษ—aya, yana ba masu haษ“aka damar yin aiki da inganci tare da girma. Bayan adana wides da tsawo, da girma aji yana ba da hanyoyi don:

  • ฦ˜irฦ™irar sabon girma wanda ke wakiltar mafi girman girma biyu
  • Saita girman girman
  • Maimaita girman girman

A ฦ™arshe, samun girman allo a Java yana da sauฦ™i godiya ga Toolkit da kuma girma azuzuwan bayar da java.awt kunshin. Ta hanyar amfani da waษ—annan azuzuwan da hanyoyin da aka bayar, masu haษ“akawa na iya ฦ™irฦ™irar aikace-aikacen amsawa da daidaitawa waษ—anda ke ษ—aukar nau'ikan allo daban-daban da haษ“aka ฦ™warewar mai amfani akan na'urori daban-daban.

Shafi posts:

Leave a Comment