Tag: background image

Java:保持JPanel背景图像的纵横比

我有一个带有绘制背景图像的JPanel和一个布局pipe理器,其中包含所有的JFrame 。 背景图像相当大,我希望能够保持它的宽高比,无论是在一个大的或小的显示器上。 最终,我希望能够将我的LayoutManager和其单元格中的较小图像粘贴到背景图片上。 我环顾四周寻找资源,似乎很多例子使用了一个BufferedImage但我不是; 这会造成一个问题吗? 我将在下面张贴我的代码来绘制图像,如果我缺less任何信息,请让我知道。 public class MonitorPanel extends JPanel { Image img; public MonitorPanel() throws MalformedURLException { //add components try { img = ImageIO.read(new File("src/customer_vlans.jpg")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } protected void paintComponent(Graphics g) { //paint background image super.paintComponent(g); //g.drawImage(img, 0, 0, getWidth(), getHeight(), […]

CSS3背景图片过渡

我正在尝试使用CSS转换来实现“淡入淡出”效果。 但我不能得到这个与背景图像工作… CSS: .title a { display: block; width: 340px; height: 338px; color: black; background: transparent; /* TRANSITION */ -webkit-transition: background 1s; -moz-transition: background 1s; -o-transition: background 1s; transition: background 1s; } .title a:hover { background: transparent; background: url(https://lh3.googleusercontent.com/-p1nr1fkWKUo/T0zUp5CLO3I/AAAAAAAAAWg/jDiQ0cUBuKA/s800/red-pattern.png) repeat; /* TRANSITION */ -webkit-transition: background 1s; -moz-transition: background 1s; -o-transition: background 1s; transition: background 1s; […]