Tag: background

如何在JTable上添加图像背景,滚动JTable时不滚动

我需要在我的JTable后面添加一个图像背景,滚动我的JTable时不应该缩小。 目前我添加了一个Image behing my JTable。 使用绘画方法。 public void paint(Graphics g) { // First draw the background image – tiled Dimension d = getSize(); for (int x = 0; x < d.width; x += image.getIconWidth()) for (int y = 0; y < d.height; y += image.getIconHeight()) g.drawImage(image.getImage(), x, y, null, null); // Now let the regular […]

如果app在后台,如何使用fcm从服务器发送数据?

我从服务器向我的应用程序发送fcm通知。 我从服务器发送包含user_id的数据。 如果app在前台,我将在FirebaseMessageService类中获取此userId。 但是当应用程序处于后台时却没有得到它。 由于FirebaseMessagingService类仅在应用程序位于前台时才会执行。 那么当应用程序处于后台时,如何获得此ID? public class MyFirebaseMessagingService extends FirebaseMessagingService { private static final String TAG = “MyFirebaseMsgService”; private String mUserId; private Boolean mUpdateNotification; @Override public void onMessageReceived(RemoteMessage remoteMessage) { //Displaying data in log //It is optional Log.d(TAG, “From: ” + remoteMessage.getFrom()); Log.d(TAG, “Notification Message Body: ” + remoteMessage.getNotification().getBody()); String clickAction = remoteMessage.getNotification().getClickAction(); mUserId […]

游戏的无限背景

我正在研究一个Java项目来模拟直升机在一个框架中的飞行。 直升机使用箭头键在屏幕上移动。 我希望直升机能够无限移动,也就是说,当直升机到达框架的边缘时,背景应朝相反的方向移动,以产生无尽的地形效果。 这是我到目前为止的代码: import java.awt.Graphics; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; import java.net.URL; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.*; public class MainFrame extends JFrame { private static int FRAME_WIDTH = 800; private static int FRAME_HEIGHT = 500; public MainFrame() { add(new AnotherBackground(FRAME_WIDTH, FRAME_HEIGHT)); setTitle(“Helicopter Background Test”); setSize(FRAME_WIDTH,FRAME_HEIGHT); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public static void […]