1
嗨,大家好,我在java上做了一個遊戲,我希望用戶能夠調整窗口大小,而不會讓圖像變得混亂。是否有一種特定的方法用於縮放圖像以及JFrame和JFrame內部的組件,在這種情況下是按鈕,標籤,面板等? BTW。我知道如何擴展其他組件,但不能將圖像如何製作重新調整JFrame大小時將重新調整大小的圖像?
ImageIcon MainLogo = new ImageIcon (getClass().getResource("/SudokuIcons/MainLogo.png"));
ImageIcon MainLogoMenu2 = new ImageIcon (getClass().getResource("/SudokuIcons/MainLogoMenu2.png"));
ImageIcon MainLogoMenu3 = new ImageIcon (getClass().getResource("/SudokuIcons/MainLogoMenu3.png"));
ImageIcon playLogo = new ImageIcon (getClass().getResource("/SudokuIcons/PlayLogo.png"));
ImageIcon OptionsLogo = new ImageIcon (getClass().getResource("/SudokuIcons/OptionsLogo.png"));
ImageIcon HelpLogo = new ImageIcon (getClass().getResource("/SudokuIcons/HelpLogo2.png"));
ImageIcon ExitLogo = new ImageIcon (getClass().getResource("/SudokuIcons/ExitLogo.png"));
ImageIcon StartGame = new ImageIcon (getClass().getResource("/SudokuIcons/StartGame.png"));
ImageIcon ChooseDifficulty = new ImageIcon (getClass().getResource("/SudokuIcons/ChooseDifficulty.png"));
ImageIcon ChooseDifficultyMenu2 = new ImageIcon (getClass().getResource("/SudokuIcons/ChooseDifficultyMenu2.png"));
ImageIcon GoBackIcon = new ImageIcon (getClass().getResource("/SudokuIcons/GoBack.png"));
ImageIcon GoBack2Icon = new ImageIcon (getClass().getResource("/SudokuIcons/GoBack2.png"));
ImageIcon GoBack3Icon = new ImageIcon (getClass().getResource("/SudokuIcons/GoBack3.png"));
ImageIcon EasyIcon = new ImageIcon (getClass().getResource("/SudokuIcons/EasySelected1.png"));
ImageIcon MediumIcon = new ImageIcon (getClass().getResource("/SudokuIcons/MediumSelected1.png"));
ImageIcon HardIcon = new ImageIcon (getClass().getResource("/SudokuIcons/HardSelected1.png"));
ImageIcon EasyIconSelected = new ImageIcon (getClass().getResource("/SudokuIcons/EasySelected1.png"));
你嘗試了什麼?請使用ImageIcons顯示代碼 –
,請知道我是一個在2個半月前開始編程的人。調整窗口大小時,我的圖像不會調整大小,即使我使用4k分辨率的底座。他們不會縮小規模 –
發佈[MCVE](http://stackoverflow.com/help/mcve)。一定要將你的代碼複製粘貼到一個*新的項目中*,並確保它在發佈之前編譯並運行。 – user1803551