如题,请高手帮帮忙!!!!!!!!!!!
解决方案 »
- 这样的sql如何完成。。求助
- 请教一个简单的线程问题
- 关于 php ,java 取yahoo site ,yahoo link, google link ,google site
- java.lang.UnsatisfiedLinkError: nativeGetVersion thrown while loading gnu.io.RXTXCommDriver
- 那么这个结果的物理意义是什么呢?
- JTextField失去焦点遇到的问题
- 请教!!!!!!J2EE应该怎样学?
- 怎样保持旺盛的斗志??
- 如何不通过全局变量和静态变量与模态对话框进行数据交换?
- 怎样在jbuilder3的菜单编辑器中,使菜单显示中文???
- 关于TCP抓包和修改的问题
- JAVA跨类引用问题
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JDesktopPane;public class Frame2 extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
JDesktopPane desktop=new JDesktopPane();
JButton btn=new JButton("点");
public Frame2() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
} /**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
this.setContentPane(desktop);
setSize(new Dimension(400, 300));
setTitle("Frame Title");
desktop.setLayout(borderLayout1);
this.add(btn,borderLayout1.NORTH);
btn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
method();
}
});
}
public void method()
{
inner inner=new inner();
this.add(inner);
}
public static void main(String[] args)
{
new Frame2().setVisible(true);
}
}
===========================================================inner.javapackage test;import java.awt.BorderLayout;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JInternalFrame;public class inner extends JInternalFrame {
BorderLayout borderLayout1 = new BorderLayout();
JButton btn=new JButton("dialog");
public inner() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
} private void jbInit() throws Exception {
getContentPane().setLayout(borderLayout1);
this.setSize(100,100);
btn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
new Dialog1();
}
});
this.add(btn,borderLayout1.CENTER);
this.setClosable(true);
this.setResizable(true);
this.setVisible(true);
} public static void main(String[] args) {
inner inner = new inner();
}
}========================================================
Dialog1.javapackage test;import java.awt.BorderLayout;
import java.awt.Frame;import javax.swing.JDialog;
import javax.swing.JPanel;public class Dialog1 extends JDialog {
JPanel panel1 = new JPanel();
BorderLayout borderLayout1 = new BorderLayout(); public Dialog1(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
} public Dialog1() {
this(new Frame(), "Dialog1", true);
} private void jbInit() throws Exception {
panel1.setLayout(borderLayout1);
getContentPane().add(panel1);
this.setSize(100,100);
this.setVisible(true);
}
}
this(new Frame(), "Dialog1", true);上面这句才是我要的啊!不过,我怎么理解,为什么 new Frame() 一下,dialog 就显示在原来的Frame上面????这个 dialog 不是应该在在刚刚 建立的 new Frame() 上面的吗?
class doubleClick extends MouseAdapter{
private boolean click=false;
private long firstClick=0;
private long secondClick=0;
private int rowI=-1;
private JInternalFrame inframe;
public doubleClick(JInternalFrame inframe){
this.inframe=inframe;
}
public void mouseClicked(MouseEvent e){
if(click==false){
firstClick=new Date().getTime();
click=true;
}else if(click==true){
secondClick=new Date().getTime();
click=false;
}
if (Math.abs((secondClick-firstClick)) < 300 && (secondClick-firstClick) > 30){
exe(e);
}
}
public void mousePressed(MouseEvent e) {
if(click==false){
firstClick=new Date().getTime();
click=true;
}else if(click==true){
secondClick=new Date().getTime();
click=false;
}
if (Math.abs((secondClick-firstClick)) < 300 && (secondClick-firstClick) > 30){
exe(e);
}
}
private void exe(MouseEvent e){
rowI = table.rowAtPoint(e.getPoint());// 得到table的行号
if (rowI > -1){
String id=table.getValueAt(rowI, 0).toString();
dialog(id);
}
}
private void dialog(String id){//这个就是我要显示相关信息的dialog
//本来在这个函数里,没有下面的3句号,双击事件是可以的,
//但是有了这三句话,双击就变单击了,
JDialog dialog=new JDialog(new Frame(),"hello",true);
dialog.setSize(400,300);
dialog.setVisible(true);
System.out.println(id);
}
}
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JDesktopPane;public class Frame2 extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
JDesktopPane desktop=new JDesktopPane();
JButton btn=new JButton("点");
public Frame2() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
} /**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
this.setContentPane(desktop);
setSize(new Dimension(400, 300));
setTitle("Frame Title");
desktop.setLayout(borderLayout1);
this.add(btn,borderLayout1.NORTH);
btn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
method();
}
});
}
public void method()
{
inner inner=new inner();
this.add(inner);
}
public static void main(String[] args)
{
new Frame2().setVisible(true);
}
}
=======================================================package test;import java.awt.BorderLayout;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import javax.swing.table.JTableHeader;
import java.awt.event.ActionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.JInternalFrame;
import javax.swing.JTable;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;public class inner extends JInternalFrame {
BorderLayout borderLayout1 = new BorderLayout();
Object[][] object=new Object[][]{{"1","2","3"},{"4","5","6"},{"7","8","9"}};
String[] cols=new String[]{"A","B","C"};
JTableHeader header;
JTable table = new JTable(new DefaultTableModel(object,cols){
public boolean isCellEditable(int row, int column)
{
return false;
}
});
public inner() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
} private void jbInit() throws Exception {
getContentPane().setLayout(borderLayout1);
this.setSize(100,100);
this.setClosable(true);
this.setResizable(true);
table.addMouseListener(new inner_table_mouseAdapter(this));
this.getContentPane().add(table, java.awt.BorderLayout.CENTER);
header=table.getTableHeader();
this.add(header,java.awt.BorderLayout.NORTH);
this.setVisible(true);
} public static void main(String[] args) {
inner inner = new inner();
} public void table_mouseClicked(MouseEvent e) {
if (e.getClickCount()==2)
{
new Dialog1(table.getSelectedRow());
}
}
}
class inner_table_mouseAdapter extends MouseAdapter {
private inner adaptee;
inner_table_mouseAdapter(inner adaptee) {
this.adaptee = adaptee;
} public void mouseClicked(MouseEvent e) {
adaptee.table_mouseClicked(e);
}
}-=================================================================package test;import java.awt.BorderLayout;
import java.awt.Frame;import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JLabel;public class Dialog1 extends JDialog {
JPanel panel1 = new JPanel();
BorderLayout borderLayout1 = new BorderLayout();
JLabel lab = new JLabel(); public Dialog1(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
} public Dialog1(int row) {
this(new Frame(), "Dialog1", true);
lab.setText("你选中的是第"+(row+1)+"行");
this.setVisible(true);
}
private void jbInit() throws Exception {
panel1.setLayout(borderLayout1);
this.setContentPane(panel1);
this.setSize(100,100);
this.add(lab, java.awt.BorderLayout.CENTER);
}
}