优化主程序背景图像显示

This commit is contained in:
2024-06-26 23:32:42 +08:00
parent 8e6dfb275b
commit 35e07431aa
+4 -8
View File
@@ -5,6 +5,7 @@ import javax.swing.*;
import com.msksbr.LoginFrm.ScreenSize;
import com.msksbr.SQL.Connector;
import java.awt.*;
import java.awt.event.*;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -36,17 +37,12 @@ public class MainFrm extends JFrame {
countMessage.setText(countData);
bottomPanel.add(countMessage);
ImageIcon imageIcon = new ImageIcon("src/com/msksbr/images/backGround.png");
addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
int imageSize = getWidth() < getHeight() ? getWidth() : getHeight();
imageIcon.setImage(imageIcon.getImage().getScaledInstance(imageSize / 2, imageSize / 2, 0));
}
});
int imageSize = getWidth() < getHeight() ? getWidth() : getHeight();
imageIcon.setImage(imageIcon.getImage().getScaledInstance(imageSize / 2, imageSize / 2, 0));
imageIcon.setImage(imageIcon.getImage().getScaledInstance(250, 250, 0));
backLabel.setIcon(imageIcon);
setMinimumSize(new Dimension(960, 720));
setLocation();
initDialogs();
}