importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
{
JTextAreajta;
JButtonjb1,jb2;
publicTextFrame(){
jta=newJTextArea();
jscrollPanejsp=newJScrollPane(jta);//帶有滾動條的組件
add(jsp);
JPaneljp=newJPanel();
jb1=newJButton("自動換行");
jp.add(jb1);
jb2=newJButton("不換行");
jp.add(jb2);
add(jp,BorderLayout.SOUTH);
setTitle("文本區示例");
setSize(300,180);//大小
setLocationRelativeTo(null);//居中
setDefaultCloseOperation(EXIT_ON_CLOSE);//點擊窗口關閉按鈕,退出
jb1.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
jta.setLineWrap(true);//自動換行開啟
}
});
jb2.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
jta.setLineWrap(false);//自動換行關閉
}
});
}
publicstaticvoidmain(String[]args){
newTextFrame().setVisible(true);
}
}
❷ jsp,js如何獲取table的當前行的某單元格的值
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>動態表格</title>
</head>
<body>
<p>動態表格徹底研究</p>
<p>對表格單元格的添加刪除修改並對其進行移動以及拷貝等操作,是目前應用開發中常用的技術</p>
<p>
<input type="button" name="Submit" value="刷新" onclick="onRefresh()" />
<input type="button" name="Submit2" value="全選" onclick="selectall()"/>
<input type="button" name="Submit8" value="反選" onclick="inverse()" />
<input type="button" name="Submit3" value="不選" onclick="noselect()"/>
<input type="button" name="Submit4" value="添加行與列" onclick="insert_row()" />
<input type="button" name="Submit7" value="刪除選擇" onclick="delRow()" />
<input type="button" name="Submit5" value="拷貝選擇" onclick="Row()"/>
<input type="button" name="Submit92" value="居中對齊" onclick="tableAlign()"/>
<input type="button" name="Submit922" value="隔行變色" onclick="changeColor()"/>
</p>
<table width="50%" border="1" cellpadding="1" cellspacing="2" bordercolor="#CCCCCC" id="myTable">
<tr>
<td width="7%">
<label>
<input type="checkbox" name="checkbox" value="checkbox" />
</label> </td>
<td width="51%">1</td>
<td width="14%">1</td>
<td width="14%">1</td>
<td width="14%">1</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox2" value="checkbox" /></td>
<td>2</td>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox3" value="checkbox" /></td>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox4" value="checkbox" /></td>
<td>4</td>
<td>4</td>
<td>4</td>
<td>4</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox5" value="checkbox" /></td>
<td>5</td>
<td colspan="2">55</td>
<td>5</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox6" value="checkbox" /></td>
<td>6</td>
<td>6</td>
<td>6</td>
<td>56</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox7" value="checkbox" /></td>
<td>777</td>
<td>7</td>
<td>77</td>
<td>7</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox8" value="checkbox" /></td>
<td>88</td>
<td>8</td>
<td>88</td>
<td>77</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox9" value="checkbox" /></td>
<td>999</td>
<td>99</td>
<td>99</td>
<td>999</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox10" value="checkbox" /></td>
<td>10</td>
<td>10</td>
<td>10</td>
<td>10</td>
</tr>
</table>
<br />
<p></p>
<script type="text/javascript">
var form = document.forms["form1"];
var table = document.getElementById("myTable");
var selectBox = table.getElementsByTagName("input");
var tr = table.getElementsByTagName("tr");
var clicked = true;
function insert_row(){
//alert(table.rows[0].cells.length)
var thisrow = table.insertRow(0);
var thiscell = thisrow.insertCell(0);
thiscell.innerHTML = "<input type="checkbox" name="checkbox10" value="checkbox" />";
var thiscell1 = thisrow.insertCell(1);
thiscell1.innerHTML = "cell";
var thiscell2 = thisrow.insertCell(2);
thiscell2.innerHTML = "cell";
var thiscell3 = thisrow.insertCell(3);
thiscell3.innerHTML = "cell";
var thiscell4 = thisrow.insertCell(4);
thiscell4.innerHTML = "cell";
thiscell4.align = "center";
}
function insert_Cell(){
var y = table.rows[0].insertCell(0);
y.colSpan="2";
y.innerHTML = "sssss";
}
function selectall(){
for(i=0;i<selectBox.length;i++){
selectBox[i].checked = true;
}
}
function noselect(){
for(i=0;i<selectBox.length;i++){
selectBox[i].checked = false;
}
}
function inverse(){
for(i=0;i<selectBox.length;i++){
if(selectBox[i].checked){
selectBox[i].checked = false;
}else{
selectBox[i].checked = true;
}
}
}
function delRow(){
for(i=selectBox.length-1;i>=0;i--){
//alert(typeof(selectBox[i]));
if(selectBox[i].checked){
table.deleteRow(i);
}
}
}
function onRefresh(){
location.reload();
}
function Row(){
for(i=0;i<selectBox.length;i++){
if(selectBox[i].checked){
//var table = document.getElementById("Table");
var tablerow = table.insertRow(table.rows.length);
tablerow.innerHTML = table.rows[i].innerHTML;
}
}
}
function tableAlign(){
for(i=0;i<selectBox.length;i++){
if(selectBox[i].checked && clicked){
table.rows[i].align = "center";
}
}
}
function changeColor(){
var skip = true;
for(i=0;i<tr.length;i++){
if(skip){
tr[i].bgColor = "#cccccc";
skip = false;
}else{
tr[i].bgColor = "#ffffff";
skip = true;
}
}
}
</script>
</body>
</html>
運行效果:
❸ 在用JSP做一個登錄頁面。怎麼使得那個登錄框在屏幕的正中間顯示
一般登錄來框使用fieldset做的:自
<form name="myform">
<fieldset>
<legend>登錄</legend>
價格:
<input type="text" name="bookprice" value="50"><br/>
書名:
<input type="text" name="bookname" value="Javascript入門教程"><br/>
作者:
<input type="text" name="bookauthor" value="小明"><br/>
<input type="button" onclick="getPrice()" value="計算折扣價">
</fieldset>
</form>
直接對fieldset元素用以下樣式即可:
<style type="text/css">
fieldset {
margin:0px auto;
width:300px;
}
</style>
❹ jsp中window.showModalDialog如何隱藏地址欄(jsp遵循了W3C)
不應該啊,下面是我寫的一個,是沒有地址欄的
<html>
<head>
<title>原來窗口</title>
<meta http-equiv = "content-type" content = "text/html; charset = gb2312">
<script type = "text/javascript">
//新開窗口,並傳值
function goToWD() {
window.open("newWindow.html", "", "width = 500px, height = 400px") // 新打開一個窗口頁面
}
//新開對話框,並傳值
function goToDL() {
var goToContent = document.getElementById("js_go").value; //初始化要傳過去的內容
//新打開一個對話框,方法中將goToContent寫下進方法參數傳送過去,新對話框用window.dialogArgument接收。
//新對話框返回的值就返回給這個方法
var backContent = window.showModalDialog("newDialog.html", goToContent, "dialogWidth: 500px; height: 400px;")
document.getElementById("js_back").value = backContent; //將傳回來的值賦給js_back
}
</script>
</head>
<body>
要送出去的值:
<input type = "text" id = "js_go" value = "">
<br><br>
<input type = "button" id = "goToWindow" value = "點擊打開一個新窗口,並將送出去的值傳過去" onclick = "goToWD()">
<br><br>
<input type = "button" id = "goToDialog" value = "點擊打開一個新對話框,並將送出去的值傳過去" onclick = "goToDL()">
<br><br>
新打開元素那邊輸入返回回來的值:
<input type = "text" id = "js_back" value = "" >
</body>
</html>
<html>
<head>
<title>新打開的一個對話框</title>
<meta http-equiv = "content-type" content = "text/html; charset = gb2312">
<script type = "text/javascript">
function catchContent() {
//用window.dialogArguments接收,父窗口作為方法參數傳過來的值
document.getElementById("js_come").value = window.dialogArguments;
}
function backTW() {
//用window.returnValue將值傳回去,父窗口需要接收
window.returnValue = document.getElementById("js_goBack").value;
window.close();
}
</script>
</head>
<body onload = "catchContent()">
被原來的窗口傳過來的值,此窗口接收:
<input type = "text" id = "js_come" value = "">
<br><br>
輸入想要傳回去的內容:
<input type = "text" id = "js_goBack" value = "">
<br><br>
<input type = "button" id = "backToWindow" value = "OK傳回去吧" onclick = "backTW()">
</body>
</html>
❺ 如何實現如點百度「登陸」時彈出登陸框(網頁製作)
最方便的實現方式是:
1、在要打開登錄框的頁面創建一個div,設置div的樣式表z-index為本頁面最大的,以及設置為居中,調整其大小並將其隱藏;
2、創建一個登錄的頁面,頁面中內容不超過div的大小(也可以部分頁面,都寫在上一個jsp中,但如果別的頁面也需要用就會寫很多個了);
3、在有登錄按鈕的頁面,設置登錄按鈕的事件,點擊後彈出div並嵌套登錄的頁面。
下面為示例代碼:
login.jsp
<style>
.loginDiv{width:400px;height:450px;}
</style>
<center>
<divclass="loginDiv">
<from>
賬號:<inputtype='text'id='name'/><br>
賬號:<inputtype='password'id='pwd'/><br>
<buttontype='submit'>登錄</button>
</form>
</center>
</div>
other.jsp
#loginDiv{width:400px;height:450px;z-index:99999;}
<script>
//jQuery語言
$(
$('#loginDiv').hide();
$('#btnLogin').click(function(){
$('#loginDiv').dialog({
width:400,
height:450,
modal:true,
resizable:false,
title:dialogTitle,
close:function(e,u){
$('#loginDiv').empty();
$(this).dialog("destroy");
});
});
);
</script>
<buttonid='btnLogin'type='button'>登錄</button>
<divid='loginDiv'>
<iframeurl='login.jsp></iframe>
<iframestyle="border:0;width:100%;height:100%;"></iframe>
</div>
❻ java 怎麼把輸出流寫到excel文件中
如果是JSP頁面要導出成excel,依靠javascript就可以實現了,具體你試試上面的代碼
<input type="button" value="保存為 Excel">
<script language="javascript">
function AllAreaExcel() {
var title;
title=document.getElementsByTagName("table")[0].childNodes.item(0).childNodes(0).childNodes(0).innerText;
alert(title);
var oXL = new ActiveXObject("Excel.Application");
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
//從excel的第5行開始插入
oSheet.Range("A5").select;
oWB .Worksheets(1).Activate;
oSheet.Cells(3,1).Value=title; //在第3行插入報表頭
oWB.Worksheets(1).Range("A3:I3").merge(); // 合並單元格區域 A3:I3
oWB.Worksheets(1).Range("A3:I3").HorizontalAlignment=3; //居中對齊A3:I3
var sel=document.body.createTextRange();
sel.moveToElementText(table1); //table 的ID值
sel.select();
sel.execCommand("Copy");
oSheet.Paste();
oXL.Visible = true;
}
</script>
❼ 如何在java程序中,當點擊一個按鈕後,關閉當前窗口,開啟一個新的窗口。
JButtonbtn=newJButton(newAbstractAction("關閉並打開"){@(ActionEvente){oldFrame.dispose();//關閉並銷毀,無需銷毀可採用oldFrame.setVisible(false);newFrame.setVisible(true);//打開新窗口}});