从Fritz.box登录页面
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
public class TrafficLight extends JFrame implements ActionListener {
JButton b1, b2, b3;
Signal green = new Signal(Color.green);
Signal yellow = new Signal(Color.yellow);
Signal red = new Signal(Color.red);
public TrafficLight(){
super("Traffic Light");
getContentPane().setLayout(new GridLayout(2, 1));
b1 = new JButton("Red");
b2 = new JButton("Yellow");
b3 = new JButton("Green");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
green.turnOn(false);
yellow.turnOn(false);
red.turnOn(true);
JPanel p1 = new JPanel(new GridLayout(3,1));
p1.add(red);
p1.add(yellow);
p1.add(green);
JPanel p2 = new JPanel(new FlowLayout());
p2.add(b1);
p2.add(b2);
p2.add(b3);
getContentPane().add(p1);
getContentPane().add(p2);
pack();
}
public static void main(String[] args){
TrafficLight tl = new TrafficLight();
tl.setVisible(true);
}
public void actionPerformed(ActionEvent e){
if (e.getSource() == b1){
green.turnOn(false);
yellow.turnOn(false);
red.turnOn(true);
} else if (e.getSource() == b2){
yellow.turnOn(true);
green.turnOn(false);
red.turnOn(false);
} else if (e.getSource() == b3){
red.turnOn(false);
yellow.turnOn(false);
green.turnOn(true);
}
}
}
class Signal extends JPanel{
Color on;
int radius = 40;
int border = 10;
boolean change;
Signal(Color color){
on = color;
change = true;
}
public void turnOn(boolean a){
change = a;
repaint();
}
public Dimension getPreferredSize(){
int size = (radius+border)*2;
return new Dimension( size, size );
}
public void paintComponent(Graphics g){
g.setColor( Color.black );
g.fillRect(0,0,getWidth(),getHeight());
if (change){
g.setColor( on );
} else {
g.setColor( on.darker().darker().darker() );
}
g.fillOval( border,border,2*radius,2*radius );
}
}
如何设置用户名和密码以从html文件自动登录?
我的自动登录代码:
<div id="dialogContent" name="" class="dialog_content">
<form id="loginForm" name="" class="loginForm" method="post" action="">
<div id="" name="" class="formular">
<p id="" name="" class="">Melden Sie sich mit Ihrem Benutzernamen und Ihrem Kennwort an.</p>
<label for="uiViewUser">Benutzername</label>
<select id="uiViewUser" name="uiUser" class="">
<option value="">Bitte wählen ...</option>
<option value="ftpuser">ftpuser</option>
<option value="mha">mha</option>
</select>
<br>
<p id="uiSelectUsername" name="" class="form_input_note ErrorMsg hidden">Bitte geben Sie einen Benutzernamen an.</p>
<label for="uiPass">Kennwort</label>
<input type="password" id="uiPass" name="uiPass">
<div id="uiLoginError" name="" class="hidden">
<p id="" name="" class="error_text">Anmeldung fehlgeschlagen.</p>
<p id="" name="" class="error_text">Haben Sie sich vielleicht vertippt oder fehlt Ihnen die Zugangsberechtigung für diesen Bereich?</p>
<p id="uiWait" name="" class="error_text"></p>
</div>
</div>
<div id="" name="" class="btn_form_foot">
<input type="hidden" id="uiResp" name="response" value="">
<input type="hidden" id="" name="lp" value="">
<input type="hidden" id="username" name="username" value="">
<div id="forgot_pass" name="" class="">
<a id="" name="" class="" target="" href="">Kennwort vergessen?</a>
</div>
<button type="submit" id="submitLoginBtn" name="" class="" tabindex="3">Anmelden</button>
</div>
</form>
自动填充登录数据有什么问题?该代码无法自动登录。