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);//打开新窗口}});