📄 synthframe.java
字号:
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.synth.SynthLookAndFeel;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.plaf.motif.MotifLookAndFeel;
/**
*
* @author MAbernethy
*/
public class SynthFrame extends JFrame
{
private JPanel jContentPane = null;
private JLabel lblName = null;
private JLabel lblPass = null;
private JLabel lblSound = null;
private JButton btnCancel = null;
private JButton btnOk = null;
private JTextField txtName = null;
private JTextField txtPass = null;
private JCheckBox checkNew = null;
public static void main(String[] args) throws Exception
{
Runnable runner = new Runnable()
{
public void run()
{
try
{
SynthLookAndFeel synth = new SynthLookAndFeel();
synth.load(SynthFrame.class.getResourceAsStream("demo.xml"), SynthFrame.class);
UIManager.setLookAndFeel(synth);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
};
SwingUtilities.invokeAndWait(runner);
new BackgroundPainter();
SynthFrame f = new SynthFrame();
f.addWindowListener(new
WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
f.setVisible(true);
}
public SynthFrame()
{
super();
initialize();
}
private void initialize()
{
this.setSize(341, 275);
this.setContentPane(getJContentPane());
this.setTitle("Login");
}
private JPanel getJContentPane()
{
if (jContentPane == null)
{
jContentPane = new JPanel();
GridBagConstraints consGridBagConstraints2 = new GridBagConstraints();
GridBagConstraints consGridBagConstraints1 = new GridBagConstraints();
GridBagConstraints consGridBagConstraints3 = new GridBagConstraints();
GridBagConstraints consGridBagConstraints5 = new GridBagConstraints();
GridBagConstraints consGridBagConstraints6 = new GridBagConstraints();
GridBagConstraints consGridBagConstraints7 = new GridBagConstraints();
GridBagConstraints consGridBagConstraints4 = new GridBagConstraints();
GridBagConstraints consGridBagConstraints8 = new GridBagConstraints();
GridBagConstraints consGridBagConstraints9 = new GridBagConstraints();
consGridBagConstraints2.insets = new Insets(12,36,16,6);
consGridBagConstraints2.ipady = 4;
consGridBagConstraints2.ipadx = 25;
consGridBagConstraints2.gridy = 1;
consGridBagConstraints2.gridx = 0;
consGridBagConstraints1.insets = new Insets(42,46,12,6);
consGridBagConstraints1.ipady = 3;
consGridBagConstraints1.ipadx = 10;
consGridBagConstraints1.gridy = 0;
consGridBagConstraints1.gridx = 0;
consGridBagConstraints5.insets = new Insets(13,18,35,7);
consGridBagConstraints5.ipady = -1;
consGridBagConstraints5.ipadx = 22;
consGridBagConstraints5.gridy = 3;
consGridBagConstraints5.gridx = 1;
consGridBagConstraints6.insets = new Insets(38,6,8,29);
consGridBagConstraints6.ipady = 7;
consGridBagConstraints6.ipadx = 166;
consGridBagConstraints6.fill = GridBagConstraints.HORIZONTAL;
consGridBagConstraints6.weightx = 1.0;
consGridBagConstraints6.gridwidth = 2;
consGridBagConstraints6.gridy = 0;
consGridBagConstraints6.gridx = 1;
consGridBagConstraints3.insets = new Insets(12,39,14,13);
consGridBagConstraints3.ipady = 5;
consGridBagConstraints3.ipadx = 14;
consGridBagConstraints3.gridy = 2;
consGridBagConstraints3.gridx = 0;
consGridBagConstraints8.insets = new Insets(13,7,13,42);
consGridBagConstraints8.ipadx = 28;
consGridBagConstraints8.gridy = 2;
consGridBagConstraints8.gridx = 1;
consGridBagConstraints7.insets = new Insets(9,6,12,0);
consGridBagConstraints7.ipady = 7;
consGridBagConstraints7.ipadx = 88;
consGridBagConstraints7.fill = GridBagConstraints.HORIZONTAL;
consGridBagConstraints7.weightx = 1.0;
consGridBagConstraints7.gridy = 1;
consGridBagConstraints7.gridx = 1;
consGridBagConstraints4.insets = new Insets(13,0,35,34);
consGridBagConstraints4.ipady = -1;
consGridBagConstraints4.gridy = 3;
consGridBagConstraints4.gridx = 2;
jContentPane.setLayout(new GridBagLayout());
jContentPane.add(getLblName(), consGridBagConstraints1);
jContentPane.add(getLblPass(), consGridBagConstraints2);
jContentPane.add(getLblSound(), consGridBagConstraints3);
jContentPane.add(getBtnCancel(), consGridBagConstraints4);
jContentPane.add(getBtnOk(), consGridBagConstraints5);
jContentPane.add(getTxtName(), consGridBagConstraints6);
jContentPane.add(getTxtPass(), consGridBagConstraints7);
jContentPane.add(getCheckNew(), consGridBagConstraints8);
}
return jContentPane;
}
private JLabel getLblName() {
if(lblName == null) {
lblName = new JLabel();
lblName.setText("User Name:");
lblName.setHorizontalAlignment(SwingConstants.RIGHT);
}
return lblName;
}
private JLabel getLblPass() {
if(lblPass == null) {
lblPass = new JLabel();
lblPass.setText("Password:");
lblPass.setHorizontalAlignment(SwingConstants.RIGHT);
}
return lblPass;
}
private JLabel getLblSound() {
if(lblSound == null) {
lblSound = new JLabel();
lblSound.setText("New User?");
lblSound.setHorizontalAlignment(SwingConstants.RIGHT);
}
return lblSound;
}
private JButton getBtnCancel() {
if(btnCancel == null) {
btnCancel = new JButton();
btnCancel.setText("Cancel");
}
return btnCancel;
}
private JButton getBtnOk() {
if(btnOk == null) {
btnOk = new JButton();
btnOk.setText("OK");
btnOk.addActionListener(new
ActionListener(){
public void actionPerformed(ActionEvent event){
JOptionPane.showMessageDialog(null,"ABOUTMSG","帮助",1);
}
});
}
return btnOk;
}
private JTextField getTxtName() {
if(txtName == null) {
txtName = new JTextField();
}
return txtName;
}
private JTextField getTxtPass() {
if(txtPass == null) {
txtPass = new JTextField();
}
return txtPass;
}
private JCheckBox getCheckNew() {
if(checkNew == null) {
checkNew = new JCheckBox();
}
return checkNew;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -