❶ java 界面设计
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import java.awt.GridBagConstraints;
public class Test1 extends JPanel {
private static final long serialVersionUID = 1L;
private JSplitPane jSplitPane = null;
/**
* This is the default constructor
*/
public Test1() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.gridy = 0;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.gridx = 0;
this.setSize(300, 200);
this.setLayout(new GridBagLayout());
this.add(getJSplitPane(), gridBagConstraints);
}
/**
* This method initializes jSplitPane
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane() {
if (jSplitPane == null) {
jSplitPane = new JSplitPane();
}
return jSplitPane;
}
}
楼主是不是要这种的效果???
❷ 用java设计简单的windows窗口
给你推荐一本书,你说的俩个例子书上都有,《java实例精通》李相国主编,黄皮书!不好意思我的电脑没有联网,我用手机不方便!
❸ java界面设计
我觉得,页面布局什么的,这个不用说了吧。。就是逻辑而已,点击“第一步”,判断有没有输入,如果有输入,判断是不是正整数,如果条件符合,那么第一格显示输入的值,然后第二格,处理下(其实就是for循环String,倒序)然后第三格=第一格+第二格的值;
第二步,同样获得第一步最后一个的和值,然后类似第一步。如下类似
❹ 用java 在窗体中画一个简单图形。
Graphics2D a2d= (Graphics2D)g; 去掉这句你试试,这句话我觉得多此一举。
因为你不能确定这个过程中发生了什么转换过程之类的,直接g.setColor(....);就行了。
❺ java图形界面设计
import javax.swing.*;import java.awt.*;import java.awt.event.*;
public class li53{
public static void main(String args[]){
ButtonDemo myButtonGUI=new ButtonDemo();
myButtonGUI.setVisible(true);
}
}
class ButtonDemo extends JFrame implements ActionListener{
public static final int Width=250;
public static final int Height=200;
ButtonDemo(){
setSize(Width,Height); setTitle("按钮事件样例");
Container conPane=getContentPane();
conPane.setBackground(Color.blue);
conPane.setLayout(new FlowLayout());
JButton redBut=new JButton("red");
redBut.addActionListener(this);
conPane.add(redBut);
JButton greenBut=new JButton("green");
greenBut.addActionListener(this);
conPane.add(greenBut);
}
public void actionPerformed(ActionEvent e){
Container conPane=getContentPane();
if(e.getActionCommand().equals("red"))
conPane.setBackground(Color.red);
else if(e.getActionCommand().equals("green"))
conPane.setBackground(Color.green);
}
}
我帮你改好了,在
else if(e.getActionCommand().equals("green"));//这里多了个分号
conPane.setBackground(Color.green);
所以编程习惯要养成,在if后面无论几句话都要用{}将方法体括起来,你这样很容易错的。改起来也吃力。
❻ java窗体满分项目
给你个建议,不要学习java中的swing,java在这方面,自己都不玩了。
去学习:spring->spring boot->spring cloud吧
如果你针对窗体项目感兴趣,去学习.NET的wpf
❼ JAVA图形界面设计
importjava.awt.Color;
importjava.awt.Font;
importjava.awt.Graphics;
importjavax.swing.JFrame;
importjavax.swing.JPanel;
{
publicTestFrame(){
add(newCirclePanel());
setSize(300,230);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
} publicstaticvoidmain(String[]args){
newTestFrame().setVisible(true);
}
//绘制图形的面板
classCirclePanelextendsJPanel{
intR=50;//直径
@Override
protectedvoidpaintComponent(Graphicsg){
super.paintComponent(g);
g.setColor(Color.BLUE);//设置颜色为蓝色
g.drawOval(80,30,R,R);//圆形外接矩形的左顶点坐标是80,30;
g.setColor(Color.BLACK);
g.drawOval(120,30,R,R);
g.setColor(Color.RED);
g.drawOval(160,30,R,R);
g.setColor(Color.YELLOW);
g.drawOval(100,65,R,R);
g.setColor(Color.GREEN);
g.drawOval(140,65,R,R);
g.setColor(Color.BLUE);//设置颜色为蓝色
g.setFont(newFont("宋体",Font.BOLD,22));//设置字体
g.drawString("奥运五环旗",90,160);
}
}
}
❽ 用java做一个窗口
java做窗口的话,需要用swing技术,之后创建JFrame 等组件,即可完成窗口创建工作。
package inter.frame;import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;public class MenuTest { /**
* @param args
*/
JFrame frame; //定义一个窗口架构
JMenuBar mb;//定义窗口的菜单工具栏
JMenu m; //定义菜单
JMenuItem mi1;//定义菜单的内容
JMenuItem mi2; //定义菜单的内容
public MenuTest() {
initFrame();
initAction();
}
public void initFrame() {
frame = new JFrame();
mb = new JMenuBar();
m = new JMenu("学生查询");
mi1 = new JMenuItem("确认");
mi2 = new JMenuItem("取消"); m.add(mi1);
m.add(mi2);
mb.add(m);
frame.add(mb, BorderLayout.NORTH);
frame.setSize(300, 300); //设置窗口大小
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置退出时关闭窗口
frame.setVisible(true);//设置窗口可见
} public void initAction() {
mi1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// 具体实现代码根据实际要求填写
System.out.println("click");
JOptionPane.showMessageDialog(null, "你点击了确定按钮");
}
});
mi2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// 具体实现代码根据实际要求填写
JOptionPane.showMessageDialog(null, "你点击了取消按钮");
}
});
} public static void main(String[] args) {
new MenuTest();//执行菜单创建
}}
❾ java窗口程序制作
麻烦能把答案也发一份给我么?[email protected]
我的邮箱,我也用sql~麻烦了~急呀~555
❿ 关于窗体的java程序设计怎么设计
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Test {
private JFrame frame;
private JTextField text1;//第一个文本框
private JButton ;//复制按钮
private JTextField text2;//第二个文本框
public Test() {
frame = new JFrame("Test");
text1 = new JTextField(10);
= new JButton("复制");
text2 = new JTextField(10);
init();
addEventHandler();
}
private void addEventHandler() {//给按钮添加事件
.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
text2.setText(text1.getText());
}
});
}
public void init() {//初始化
JPanel p=new JPanel();
p.add(text1);//把组件都添加到JPanel
p.add();
p.add(text2);
frame.add(p);//JPanel添加到JFrame
}
public void show() {
frame.setLocation(100, 100);
frame.setSize(360, 100);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Test().show();
}
}
运行后,有个窗口,窗口中有两个文本框,中间有个复制按钮,在第一个文本框中输入内容,然后按下复制按钮,第二个文本框中就会显示输入的内容