📄 tab1_2.html
字号:
<html>
<body>
<font face="Verdana" size="3"><font color="#0000FF">FadeComponent</font> subclasses
<font color="#0000FF">JComponent</font>, which
again subclasses <font color="#0000FF">Container</font>. <font color="#0000FF">FadeComponent</font> changes alpha value of the
<font color="#0000FF">Graphics</font>
object passed to it for drawing, and the same <font color="#0000FF">Graphics</font> object is then passed to
its child components (if any) for their respective drawing.</font>
<p><font face="Verdana" size="3">This means the easiest way to use
<font color="#0000FF">FadeComponent</font>
is to create your UI components using standard swing components and then add
it/them to a <font color="#0000FF">FadeComponent</font> object.</font><font face="Verdana"> In this demo case, a <font color="#0000FF">JLabel</font> object with an icon image is
created and then added to a <font color="#0000FF">FadeComponent</font> object.</font></p>
<p>
<font face="Verdana" size="3">A complete working code is given in this
demo case. For the rest of the demo cases, only code segment is given.
Please note that code presented in this panel maybe different from the actual
code in the demo program due to various reasons. Nevertheless, they do result in
the same effect.</font> </p>
<hr>
<pre><font face="Courier New" size="3">
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import hysun.util.FadeComponent;
public class TestFade {
public static void main(String args[]) {
JFrame frame = new JFrame("Test Fade");
JPanel panel = new JPanel();
panel.setBackground(Color.white);
frame.getContentPane().add(panel);
final FadeComponent fc = new FadeComponent();
fc.setPreferredSize(new Dimension(340, 220));
<font color="#FF0000"> fc.setPattern("i_500_o_500");
fc.setLoops(-1);
fc.setSteps(100);</font> // = default value, can be omitted
<font color="#FF0000"> fc.setPrecision(50);</font> // = default value, can be omitted
panel.add(fc); // FlowLayout by default
JLabel label = new JLabel();
label.setIcon(new ImageIcon(PUT_YOUR_OWN_IMAGE_URL));
label.setBounds(0, 0, 320, 190);
fc.add(label); // no LayoutManager used.
frame.addWindowListener(new WindowAdapter() {
public void windowOpened(WindowEvent e) {
<font color="#FF0000"> fc.startAnimation();</font>
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}</font></pre>
<hr>
<p><font face="Verdana" size="3">Only code in red is special about
<font color="#0000FF">FadeComponent</font>, the rest are just normal swing
component code. Also notice it is always a good practice to set the preferred
size of FadeComponents.</font></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -