A cikin duniyar ci gaban yanar gizo da ƙira, mahimmancin launuka na maɓalli ba za a iya faɗi ba. Waɗannan ƙananan abubuwa masu mahimmanci amma suna iya yin babban bambanci a cikin ƙwarewar mai amfani da gaba ɗaya nasarar gidan yanar gizo ko aikace-aikace. A cikin wannan labarin, za mu gano hanyar da za a zabi mafi dacewa da tasiri maɓalli launuka, kazalika da yadda za a aiwatar da su ta amfani da Java. Za mu kuma tattauna dakunan karatu daban-daban da ayyuka da za a iya amfani da su don cimma wannan, tare da misalai da bayani kowane mataki na hanya.
### Maganin Matsalolin Kalar Button
Lokacin zayyana aikace-aikacen gidan yanar gizo ko dubawa, yana da mahimmanci don tabbatar da cewa maɓallan duka suna da sha'awar gani kuma ana iya ganewa cikin sauƙi. Wannan yana nufin zabar launuka waɗanda ba kawai aesthetically m amma kuma yana ba da ma'ana da aiki bayyananne. Hanya ɗaya don magance wannan matsala ita ce ta yin amfani da ƙayyadaddun ƙayyadaddun jagororin launi ko palette mai launi wanda aka tabbatar da tasiri a ƙirar ƙwarewar mai amfani. Wata hanyar ita ce gudanar da bincike mai zurfi kan ka'idar launi, ilimin halin mai amfani, da yanayin kasuwa don fito da tsarin launi na musamman wanda ya dace da bukatun aikin da ke hannu.
#### Bayanin mataki-mataki na lambar Java
Anan, zamu ba da bayanin mataki-mataki na lambar Java mai sauƙi wanda zai ba mu damar canza launin maɓalli a cikin aikace-aikacen gidan yanar gizo ta amfani da sanannen. JavaFX tsarin.
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.stage.Stage; public class ButtonColor extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { Button button = new Button("Click me!"); button.setStyle("-fx-base: #00FF00;"); StackPane root = new StackPane(); root.getChildren().add(button); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Button color using JavaFX"); primaryStage.setScene(scene); primaryStage.show(); } }
1. A cikin 'yan layi na farko, mu shigo da azuzuwan JavaFX da fakitin da suka dace don aikace-aikacen mu.
2. Sa'an nan kuma mu ƙirƙiri wani sabon ajin jama'a mai suna 'ButtonColor', yana tsawaita ajin 'Application' wanda ke cikin tsarin JavaFX.
3. A cikin babbar hanyar, muna kiran hanyar 'launch()' da ajin Application ke bayarwa don fara aikace-aikacen JavaFX.
4. Hanyar `fara()' an soke ta don ayyana babban tsarin aikace-aikacen mu. A cikin wannan hanyar, mun ƙirƙiri sabon misalin Button, saita rubutunsa, da ayyana launin tushe ta amfani da kayan CSS '-fx-base'. A cikin wannan misalin, mun zaɓi launin kore mai haske (`#00FF00`).
5. Na gaba, mun ƙirƙiri kwandon shimfidar 'StackPane' kuma mu ƙara maɓallin a ciki. Sa'an nan kuma mu ƙirƙiri sabon `Sene' kuma mu saita girman taga (300×250).
6. A ƙarshe, mun saita taken taga, saita wurin da za a nuna a matakin farko (wanda aka shiga cikin hanyar azaman hujja), sannan mu kira hanyar `show()' don ganin taga.
JavaFX da Muhimmancin sa
JavaFX shine tushen bude-bude, tsarin tushen Java don ƙirƙirar aikace-aikacen abokin ciniki masu wadata waɗanda aka tsara don aiki akan nau'ikan na'urori masu yawa - daga tebur zuwa kwamfutar hannu da wayoyi. Yana ba da tsarin fasali mai ƙarfi da sassauƙa, yana ba masu haɓaka damar ƙirƙirar UI masu ci gaba da nagartaccen abu. Ɗaya daga cikin waɗannan siffofi shine iya salon abubuwan UI ta amfani da CSS, wanda ya sa ya fi sauƙi ga masu zane-zane da masu haɓakawa don haɗin gwiwa da ƙirƙirar aikace-aikace masu ban sha'awa.
- JavaFX Scene magini: Wannan kayan aikin shimfidawa ne na gani wanda ke taimaka wa masu haɓaka ƙirƙira ƙirar UI ta hanyar ja da sauke abubuwan UI a kan zane kuma nan take ganin yadda za su bayyana a aikace-aikacen ƙarshe. Yana haifar da lambar FXML, wanda za a iya haɗa shi cikin aikin aikace-aikacen Java.
- JavaFX Animation da Tasirin: JavaFX yana ba da cikakkiyar saiti na ɗakunan karatu da APIs don ƙirƙirar raye-raye masu santsi da rikitarwa, canzawa, da tasirin gani a cikin aikace-aikace. Waɗannan fasalulluka suna ba masu haɓakawa ikon ƙirƙirar ƙarin mu'amala da mu'amalar mai amfani da haɓaka ƙwarewar mai amfani gabaɗaya.
Ƙarin ɗakunan karatu da ayyuka na JavaFX
Baya ga fasalulluka na farko na ɗakin karatu na JavaFX, akwai ƙarin ƙarin ɗakunan karatu da ayyuka waɗanda masu haɓakawa za su iya yin amfani da su don ƙirƙirar ƙa'idodi na musamman da na musamman.
- Sarrafa FX: Wannan ɗakin karatu ne mai buɗewa wanda ke ba da tarin ingantattun iko na UI, kamar maganganu, maɓalli tare da fasalulluka mai hoto, da jujjuyawar motsin rai. Ana iya haɗa ControlsFX cikin sauƙi cikin ayyukan JavaFX don haɓaka UI da ƙwarewar mai amfani.
- JFeenix: Wannan ɗakin karatu shine aiwatar da ƙirar kayan aikin JavaFX, yana ba masu haɓaka kayan haɓaka na zamani da kyawawan abubuwan UI waɗanda aka yi wahayi daga jagororin ƙirar Google. Tare da JFoenix, aikace-aikace na iya ƙunshi nau'ikan UI masu ɗorewa tare da raye-raye masu wadata, waɗanda ke kan ƙarshen ƙirar gidan yanar gizo da ƙirar wayar hannu.
A taƙaice, launukan maɓalli suna taka muhimmiyar rawa a cikin nasarar aikace-aikacen yanar gizo da musaya. Yin amfani da tsarin JavaFX tare da ɗakunan karatu da ayyukansa yana ba masu haɓakawa da wadataccen albarkatu don ƙirƙirar kyan gani, ƙirar maɓalli masu tasiri da ƙwarewar mai amfani gaba ɗaya. Ta hanyar fahimta da sarrafa waɗannan kayan aikin, masu haɓakawa na iya kawo aikace-aikacen su zuwa sabon matsayi, duka dangane da ƙayatarwa da amfani.