getcontentpane java_Java JInternalFrame.getContentPane方法代码示例

import javax.swing.JInternalFrame; //导入方法依赖的package包/类

/**

* Adds a component on this Canvas inside a frame.

*

* @param comp The component to add to the canvas.

* @param toolBox Should be set to true if the resulting frame is

* used as a toolbox (that is: it should not be counted as a

* frame).

* @param popupPosition A preferred {@code PopupPosition}.

* @param resizable Whether this component can be resized.

* @return The {@code JInternalFrame} that was created and added.

*/

private JInternalFrame addAsFrame(JComponent comp, boolean toolBox,

PopupPosition popupPosition,

boolean resizable) {

final int FRAME_EMPTY_SPACE = 60;

final JInternalFrame f = (toolBox) ? new ToolBoxFrame()

: new JInternalFrame();

if (f.getContentPane() instanceof JComponent) {

JComponent c = (JComponent) f.getContentPane();

c.setOpaque(false);

c.setBorder(null);

}

if (comp.getBorder() != null) {

if (comp.getBorder() instanceof EmptyBorder) {

f.setBorder(Utility.blankBorder(10, 10, 10, 10));

} else {

f.setBorder(comp.getBorder());

comp.setBorder(Utility.blankBorder(5, 5, 5, 5));

}

} else {

f.setBorder(null);

}

final FrameMotionListener fml = new FrameMotionListener(f);

comp.addMouseMotionListener(fml);

comp.addMouseListener(fml);

if (f.getUI() instanceof BasicInternalFrameUI) {

BasicInternalFrameUI biu = (BasicInternalFrameUI) f.getUI();

biu.setNorthPane(null);

biu.setSouthPane(null);

biu.setWestPane(null);

biu.setEastPane(null);

}

f.getContentPane().add(comp);

f.setOpaque(false);

f.pack();

int width = f.getWidth();

int height = f.getHeight();

if (width > getWidth() - FRAME_EMPTY_SPACE) {

width = Math.min(width, getWidth());

}

if (height > getHeight() - FRAME_EMPTY_SPACE) {

height = Math.min(height, getHeight());

}

f.setSize(width, height);

Point p = chooseLocation(comp, width, height, popupPosition);

f.setLocation(p);

this.add(f, MODAL_LAYER);

f.setName(comp.getClass().getSimpleName());

f.setFrameIcon(null);

f.setVisible(true);

f.setResizable(resizable);

try {

f.setSelected(true);

} catch (java.beans.PropertyVetoException e) {}

return f;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
package project; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class DeleteStudentFrm_info extends JFrame implements ActionListener{ StudentDao studentDao = new StudentDao(); JButton btn_add = new JButton("确定"); JButton btn_del = new JButton("取消"); JLabel lb_sno = new JLabel("学号"); JLabel lb_sname = new JLabel("姓名"); JLabel lb_sex = new JLabel("性别"); JLabel lb_add = new JLabel("家庭地址"); JLabel lb_tel = new JLabel("联系"); JTextField txt_sno = new JTextField(); JTextField txt_sname = new JTextField(); JTextField txt_sex = new JTextField(); JTextField txt_add = new JTextField(); JTextField txt_tel = new JTextField(); public DeleteStudentFrm_info(String sno) { String[] temp =studentDao.queryStudents_info_one(sno); txt_sno.setText(temp[0]); txt_sname.setText(temp[1]); txt_sex.setText(temp[2]); txt_add.setText(temp[3]); txt_tel.setText(temp[4]); JPanel jp = (JPanel) this.getContentPane(); JPanel jp1 = new JPanel(); jp1.setLayout(new GridLayout(6, 2, 5, 10)); jp1.add(lb_sno); jp1.add(txt_sno); jp1.add(lb_sname); jp1.add(txt_sname); jp1.add(lb_sex); jp1.add(txt_sex); jp1.add(lb_add); jp1.add(txt_add); jp1.add(lb_tel); jp1.add(txt_tel); jp1.add(btn_add); jp1.add(btn_del); jp.add(jp1, BorderLayout.NORTH); btn_add.addActionListener(this); btn_del.addActionListener(this); this.setSize(400, 260); this.setVisible(true); this.setTitle("删除学生信息"); } public void actionPerformed(ActionEvent e) { if (e.getSource() == btn_add) { studentDao.deleteStudent_sno(txt_sno.getText()); JOptionPane.showMessageDialog(this, "学号为" + txt_sno.getText() + "的记录删除成功!"); dispose(); } if (e.getSource() == btn_del) { dispose(); } } }
06-11

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值