先請(qǐng)編譯和運(yùn)行下面程序:
站在用戶(hù)的角度思考問(wèn)題,與客戶(hù)深入溝通,找到安澤網(wǎng)站設(shè)計(jì)與安澤網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶(hù)體驗(yàn)好的作品,建站類(lèi)型包括:網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊(cè)、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋安澤地區(qū)。
import java.util.*;
import java.io.*;
public class BadExecJavac2
{
public static void main(String args[])
{
try
{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("javac");
int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
} catch (Throwable t){
t.printStackTrace();
}
}
}
我們知道javac命令,當(dāng)不帶參數(shù)運(yùn)行javac
程序時(shí),它將輸出幫助說(shuō)明,為什么上面程序不產(chǎn)生任何輸出并掛起,永不完成呢?java文檔上說(shuō),由于有些本地平臺(tái)為標(biāo)準(zhǔn)輸入和輸出流所提供的緩沖區(qū)大小
有限,如果不能及時(shí)寫(xiě)入子進(jìn)程的輸入流或者讀取子進(jìn)程的輸出流,可能導(dǎo)致子進(jìn)程阻塞,甚至陷入死鎖。所以,上面的程序應(yīng)改寫(xiě)為:
import java.util.*;
import java.io.*;
public class MediocreExecJavac
{
public static void main(String args[])
{
try
{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("javac");
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
System.out.println("");
while ( (line = br.readLine()) != null)
System.out.println(line);
System.out.println("");
那你自己的那個(gè)對(duì)話框要做成模式的,那樣就能實(shí)現(xiàn)你的要求
寫(xiě)個(gè)類(lèi)繼承JDialog
public class Mydialog extends JDialog{
public Mydialog(){
super("這里是你對(duì)話框的標(biāo)題",true);
....................//設(shè)置好對(duì)話框的大小及位置以及里面的內(nèi)容
}
}
關(guān)鍵是那個(gè)true,如果是false就不是模式窗口了。
然后你在你按鈕的點(diǎn)擊事件里寫(xiě)new Mydialoag().setVisible(true)看看是不是能達(dá)到你說(shuō)的效果。
javascript的鎖屏代碼:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
titleJavaScript鎖屏/title
style type="text/css"
body {
font-size:12px
}
#Screen {
position:absolute;
z-index: 9998;
top: 0px;
left: 0px;
background: #000000;
display: none;
filter: alpha(Opacity=50);
}
#Message {
position: absolute;
z-index: 9999;
top: 180px;
left: 340px;
display: none;
}
/style
script language="javascript"
// 獲取寬度
function getWidth()
{
var strWidth,clientWidth,bodyWidth;
clientWidth = document.documentElement.clientWidth;
bodyWidth = document.body.clientWidth;
if(bodyWidth clientWidth){
strWidth = bodyWidth + 20;
} else {
strWidth = clientWidth;
}
return strWidth;
}
//獲取高度
function getHeight()
{
var strHeight,clientHeight,bodyHeight;
clientHeight = document.documentElement.clientHeight;
bodyHeight = document.body.clientHeight;
if(bodyHeight clientHeight){
strHeight = bodyHeight + 30;
} else {
strHeight = clientHeight;
}
return strHeight;
}
// 鎖屏
function showScreen()
{
var Element = document.getElementById('Message');
var Elements = document.getElementById('Screen');
Elements.style.width = getWidth();
Elements.style.height = getHeight();
Element.style.display = 'block';
Elements.style.display = 'block';
}
//解屏
function hideScreen()
{
var Element = document.getElementById('Message');
var Elements = document.getElementById('Screen');
Element.style.display = 'none';
Elements.style.display = 'none';
}
/script
/head
body
div id="Message"
table width="300" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC"
tr
td height="28" align="right" bgcolor="#F2F2F2"span style="cursor:pointer;" onclick="javascript:hideScreen();"關(guān)閉/span /td
/tr
tr
td height="150" align="center" bgcolor="#F2F2F2"已經(jīng)鎖屏 ..... /td
/tr
/table
/div
div id="Screen"/div
span style="cursor:pointer;" onclick="javascript:showScreen();"鎖屏/span
/body
/html