javajform的简单介绍

博主:adminadmin 2022-12-17 02:57:06 75

今天给各位分享javajform的知识,其中也会对进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

Java 里面怎么在一个JForm 里面随意按位置放控件

这样写:

JFrame

jf

=

new

JFrame();

JButton

button

=

new

JButton("OK");

//

jf.setLayout(null);//取消JFrame的默认布局

button.setBounds(x,y,width,height);

/**

x:表示button的位置x坐标

y:表示button的位置y坐标

width:button的宽

height:button的高

*/

jf.getContentPane().add(button);

你可以设置x,y的值,让button放到你想要的位置就OK啦

上面只写了主要的代码,你可以参考下

java web编程中关于form action传值问题,求教高人!

title下面

script type="text/javascript"

function asd()

{

var a=document.getElementsByName("kk")[0].value;

alert(a);

}

/script

input type="submit" value="%=(str[j][k])%" onclick="asd()"

测试一下看又数据没

一个java项目中有3个窗体,从jform1-->jform2-->jform3-->jform2,请问从jform3到jform2的代码怎么写?

1到2,需要2的对象,2到3需要3的对象。 在3中加一个属性,属性类型就是2, 2在跳转3的时候,产生3的对象,3对象.属性(这个属性是2类型)=this(这个this就是2本身),3打开后,3.属性在打开,就回到2.

不知道你懂不懂,就是一个引用的传递,将自己传过去,因为如果不传自己,将打开新的窗体,不是之前的。

java 布局管理器的问题

package util;

import java.awt.BorderLayout;

import javax.swing.BoxLayout;

import javax.swing.JButton;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JTextArea;

import javax.swing.JTextField;

import javax.swing.WindowConstants;

public class NewJFrame extends javax.swing.JFrame {

private JPanel jPanel1;

private JScrollPane jScrollPane1;

private JScrollPane jScrollPane2;

private JButton jButton1;

private JButton jButton3;

private JButton jButton2;

private JTextField jTextField1;

private JLabel jLabel1;

private JPanel jPanel2;

private JTextArea jTextArea2;

private JTextArea jTextArea1;

public static void main(String[] args) {

NewJFrame inst = new NewJFrame();

inst.setVisible(true);

}

public NewJFrame() {

super();

initGUI();

}

private void initGUI() {

try {

BorderLayout thisLayout = new BorderLayout();

setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

getContentPane().setLayout(thisLayout);

{

jPanel1 = new JPanel();

BorderLayout jPanel1Layout = new BorderLayout();

getContentPane().add(jPanel1, BorderLayout.NORTH);

jPanel1.setLayout(jPanel1Layout);

{

jScrollPane2 = new JScrollPane();

jPanel1.add(jScrollPane2, BorderLayout.CENTER);

{

jTextArea2 = new JTextArea();

jScrollPane2.setViewportView(jTextArea2);

jTextArea2.setText("jTextArea2");

}

}

{

jPanel2 = new JPanel();

BoxLayout jPanel2Layout = new BoxLayout(

jPanel2,

javax.swing.BoxLayout.Y_AXIS);

jPanel1.add(jPanel2, BorderLayout.EAST);

jPanel2.setLayout(jPanel2Layout);

jPanel2.setSize(50, 20);

{

jLabel1 = new JLabel();

jPanel2.add(jLabel1);

jLabel1.setText("jLabel1");

}

{

jTextField1 = new JTextField();

jPanel2.add(jTextField1);

jTextField1.setText("jTextField1");

}

{

jButton1 = new JButton();

jPanel2.add(jButton1);

jButton1.setText("jButton1");

}

{

jButton2 = new JButton();

jPanel2.add(jButton2);

jButton2.setText("jButton2");

}

{

jButton3 = new JButton();

jPanel2.add(jButton3);

jButton3.setText("jButton3");

}

}

}

{

jScrollPane1 = new JScrollPane();

getContentPane().add(jScrollPane1, BorderLayout.CENTER);

{

jTextArea1 = new JTextArea();

jScrollPane1.setViewportView(jTextArea1);

jTextArea1.setText("jTextArea1");

}

}

pack();

setSize(400, 300);

} catch (Exception e) {

e.printStackTrace();

}

}

}

粗糙的布局就上面的,更好的布局推荐使用JFormDesigner可视化设计器,想要啥样的布局都好用。

java 布局管理器 问题

不能,边框布局有五个部分,每个部分只能放一个组件,假如你想在一个部分里面放多个组件,建议你先把这几个组件放在jpanel里,再放入边框布局。

关于javajform和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-12-17,除非注明,否则均为首码项目网原创文章,转载请注明出处。