java怎么写应用程序界面

1.用java编写应用程序界面如下【java怎么写应用程序界面】import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; public class ChageNumber{ public static void main(String[] args){ new MyFrame().show(); } static class MyFrame extends JFrame{ private JLabel lblInput; private JLabel lblShowMax; private JTextField txtNumber1; private JTextField txtNumber2; private JTextField txtNumber3; private JTextField txtNumberMin; public MyFrame(){ init(); } public void init(){ this.setTitle(""); this.setSize(400,300); this.setLocationRelativeTo(this); this.(EXIT_ON_CLOSE); Container c=this.getContentPane(); c.setLayout(null); lblInput=new JLabel("请输入三个整数:"); lblShowMax=new JLabel("三个数最大为:"); txtNumber1=new JTextField(); txtNumber2=new JTextField(); txtNumber3=new JTextField(); txtNumberMin=new JTextField("输入完请把焦点放在这里!"); c.setBackground(Color.GRAY); lblInput.setBounds(40,40,120,30); txtNumber1.setBounds(180,40,100,30); txtNumber2.setBounds(40,80,100,30); txtNumber3.setBounds(180,80,100,30); lblShowMax.setBounds(40,150,120,30); txtNumberMin.setBounds(40,200,200,30); txtNumberMin.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { try{ long number1=Long.parseLong(txtNumber1.getText()); long number2=Long.parseLong(txtNumber2.getText()); long number3=Long.parseLong(txtNumber3.getText()); ArrayList al=new ArrayList(); al.add(number1); al.add(number2); al.add(number3); Collections.sort(al); txtNumberMin.setText("三个数最小为:"+al.get(0)); lblShowMax.setText(lblShowMax.getText()+al.get(2)); } catch(Exception ex){ new JOptionPane().showMessageDialog(null,"您输入的数字格式不正确!","提示",JOptionPane.INFORMATION_MESSAGE); } } }); c.add(lblInput); c.add(lblShowMax); c.add(txtNumber1); c.add(txtNumber2); c.add(txtNumber3); c.add(txtNumberMin); } } } 。
2.java编写有窗口界面应用程序 求代码package image; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class PanelRunner extends JFrame { private static final long serialVersionUID = 1L; private static void initPanels ( JFrame pr ) { for ( int i = 0; i < 5; i++ ) { JPanel panel = new JPanel (); switch (i) { case 0: panel.setBackground (Color.RED); panel.setPreferredSize (new Dimension (200, 100)); pr.add (panel, BorderLayout.NORTH); break; case 1: panel.setBackground (Color.YELLOW); panel.setPreferredSize (new Dimension (200, 300)); pr.add (panel, BorderLayout.EAST); break; case 2: panel.setBackground (Color.ORANGE); panel.setPreferredSize (new Dimension (200, 100)); pr.add (panel, BorderLayout.SOUTH); break; case 3: panel.setBackground (Color.WHITE); panel.setPreferredSize (new Dimension (200, 300)); pr.add (panel, BorderLayout.WEST); break; case 4: pr.add (panel, BorderLayout.CENTER); panel.setPreferredSize (new Dimension (200, 100)); panel.setLayout (new GridLayout (1, 2)); for ( int j = 0; j < 2; j++ ) { JPanel subPanel = new JPanel (); subPanel.setPreferredSize (new Dimension (200, 100)); Color color = j == 0 ? Color.BLUE : Color.GREEN; subPanel.setBackground (color); panel.add (subPanel); } break; default: break; } } } private static void initFrame ( JFrame pr ) { pr.setLayout (new BorderLayout ()); pr.setSize (600, 300); pr.setLocationRelativeTo (null); pr.setResizable (false); pr. (JFrame.EXIT_ON_CLOSE); } public static void main ( String[] args ) { SwingUtilities.invokeLater (new Runnable () { @Override public void run () { PanelRunner pr = new PanelRunner (); initFrame (pr); initPanels (pr); pr.setVisible (true); } }); } } 。
3.用java怎么写出win10应用程序的界面在win10系统中,现在用户可以非常方便的就将web应用轻松的打包,不需要经过繁琐的步骤,而且发布的web应用可以同时运行在pc和手机平台,任何人都能够完成这个打包发布流程,下面为大家介绍具体的将java web应用打包发布到win10应用商店流程 。