Java Reference
In-Depth Information
return
p
;
}
private
JPanel
initServerChoice
()
{
final
JPanel
p
=
new
JPanel
();
p
.
setLayout
(
new
GridLayout
(
6
,
1
,
5
,
2
));
p
.
add
(
new
JLabel
(
"Search At: "
));
chosenServer
.
setText
(
server
.
getHost
().
getHostName
());
p
.
add
(
chosenServer
);
chosenServer
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
event
)
{
try
{
server
=
new
Whois
(
chosenServer
.
getText
());
}
catch
(
UnknownHostException
ex
)
{
JOptionPane
.
showMessageDialog
(
p
,
ex
.
getMessage
(),
"Alert"
,
JOptionPane
.
ERROR_MESSAGE
);
}
}
}
);
return
p
;
}
private
class
LookupNames
implements
ActionListener
{
@Override
public
void
actionPerformed
(
ActionEvent
event
)
{
names
.
setText
(
""
);
SwingWorker
<
String
,
Object
>
worker
=
new
Lookup
();
worker
.
execute
();
}
}
private
class
Lookup
extends
SwingWorker
<
String
,
Object
>
{
@Override
protected
String
doInBackground
()
throws
Exception
{
Whois
.
SearchIn
group
=
Whois
.
SearchIn
.
ALL
;
Whois
.
SearchFor
category
=
Whois
.
SearchFor
.
ANY
;
String
searchForLabel
=
searchFor
.
getSelection
().
getActionCommand
();
String
searchInLabel
=
searchIn
.
getSelection
().
getActionCommand
();
if
(
searchInLabel
.
equals
(
"Name"
))
group
=
Whois
.
SearchIn
.
NAME
;
else
if
(
searchInLabel
.
equals
(
"Mailbox"
))
{
group
=
Whois
.
SearchIn
.
MAILBOX
;
}
else
if
(
searchInLabel
.
equals
(
"Handle"
))
{
group
=
Whois
.
SearchIn
.
HANDLE
;
}