עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

שאלה בקשר להצגת תמונות בג'אווה (מצ"ב קוד)

Featured Replies

פורסם

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.JFrame;


public class DisplayImage {

public static BufferedImage loadImage(String ref) {
BufferedImage bimg = null;
try {
bimg = ImageIO.read(new File(ref));
} catch (Exception e) {
e.printStackTrace();
}
return bimg;
}

public void loadAndDisplayImage(JFrame frame) {
// Load the img
BufferedImage loadImg = loadImage("Pics/23.png");
frame.setBounds(0, 0, 300, 300);
// Set the panel visible and add it to the frame
frame.setVisible(true);
// Get the surfaces Graphics object
Graphics2D g = (Graphics2D)frame.getRootPane().getGraphics();
// Now draw the image
g.drawImage(loadImg, null, 0, 0);

}

public static void main(String[] args) {
DisplayImage ia = new DisplayImage();
JFrame frame = new JFrame("Tutorials");
ia.loadAndDisplayImage(frame);
}

}

יש בעיה זה מציג את התמונה בדיוק לשניה ואחרי זה היא נעלמת...

פורסם

אני יודע שבחלונות זה קורה כי כאשר החלון מקבל פקודה ל Refresh/Redraw הוא יוצר מחדש את ה grahpics שלו ולכן אני מניח שאתה צריך להתממשק לחלק הזה של החלון ולא לטעינה שלו.

פורסם
  • מחבר

ולכן אני מניח שאתה צריך להתממשק לחלק הזה של החלון ולא לטעינה שלו.

איך אני עושה את זה?

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.