nequal:在JAVA 中怎么重新设置窗体大小。我是要QQ那种,如果窗体顶端贴近电脑屏幕最上时,窗体会收缩成最小。

你不62616964757a686964616fe58685e5aeb931333330363731要用frame.pack()方法nequal。代码如下:import java.awt.*;importjava.awt.event.*;public class TFMath { public static void main(String[] args) { new TFFrame1().launchFrame(); }}class TFFrame1 extends Frame { TextField num1, num2, num3; public void launchFrame() { num1 = new TextField(10); num2 = new TextField(10); num3 = new TextField(15); Label lblPlus = new Label(\"+\"); Button btnEqual = new Button(\"=\"); btnEqual.addActionListener(new MyMonitor111(this)); setLayout(new FlowLayout()); add(num1); add(lblPlus); add(num2); add(btnEqual); add(num3); //pack(); setVisible(true); }

nequal:在JAVA 中怎么重新设置窗体大小。我是要QQ那种,如果窗体顶端贴近电脑屏幕最上时,窗体会收缩成最小。

frame 里面可以去实现nequal,自己写代码,获取位置,计算,

java 源代码 基础点的 谢谢

汗~~~这叫300行nequal。。。

我也贴一个: 用Java写的记32313133353236313431303231363533e4b893e5b19e31333238636664事本,同样的,仅供交流,请勿商用! import javax.swing.*; import javax.swing.tree.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.io.*; class Remember extends JFrame implements TreeSelectionListener,ActionListener { JTree tree=null; JTextArea text=new JTextArea(20,20); int i=0; DefaultMutableTreeNode root; JButton b_save=new JButton(\"保存日记\"); JButton b_del=new JButton(\"删除日记\"); DefaultMutableTreeNode month[]=new DefaultMutableTreeNode[13]; Remember() { Container con=getContentPane(); DefaultMutableTreeNode root=new DefaultMutableTreeNode(\"日历记事本\"); for(i=1;i<=12;i++) { month=new DefaultMutableTreeNode(\"\"+i+\"月\"); root.add(month); } for(i=1;i<=12;i++) { if(i==1||i==3||i==5||i==7||i==8||i==10||i==12) { for(int j=1;j<=31;j++) month.add(new DefaultMutableTreeNode(j+\"日\")); } else if(i==4||i==6||i==9||i==11) { for(int j=1;j<=30;j++) month.add(new DefaultMutableTreeNode(j+\"日\")); } else { for (int j=1;j<=28;j++) month.add(new DefaultMutableTreeNode(j+\"日\")); } } b_save.addActionListener(this); b_del.addActionListener(this); tree=new JTree(root); JPanel p=new JPanel(); p.setLayout(new BorderLayout()); JScrollPane scrollpane_1=new JScrollPane(text); p.add(scrollpane_1,BorderLayout.CENTER); JPanel p_1=new JPanel(); p_1.add(b_save); p_1.add(b_del); p.add(p_1,BorderLayout.NORTH); JScrollPane scrollpane_2=new JScrollPane(tree); JSplitPane splitpane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,scrollpane_2,p); tree.addTreeSelectionListener(this); con.add(splitpane); setVisible(true); setBounds(70,80,460,320); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } public void valueChanged(TreeSelectionEvent e) { text.setText(null); if(e.getSource()==tree) { DefaultMutableTreeNode node=(DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); if(node.isLeaf()) { String str=node.toString(); for(int i=0;i<=12;i++) { if(node.getParent()==month) { try{ String temp=null; File f=new File(node.getParent().toString()+str+\".txt\"); FileReader file=new FileReader(f); BufferedReader in=new BufferedReader(file); while((temp=in.readLine())!=null) text.append(temp+\'\\n\'); file.close(); in.close(); } catch(Exception el){} } } } } } public void actionPerformed(ActionEvent e) { if(e.getSource()==b_save) { DefaultMutableTreeNode node=(DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); String str=node.toString(); if(node.isLeaf()) { try { File f=new File(node.getParent().toString()+str+\".txt\"); FileWriter tofile=new FileWriter(f); BufferedWriter out=new BufferedWriter(tofile); out.write(text.getText(),0,(text.getText()).length()); out.flush(); tofile.close(); out.close(); } catch(Exception el){} } } else if(e.getSource()==b_del) { DefaultMutableTreeNode node=(DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); String str=node.toString(); if(node.isLeaf()) { File f=new File(node.getParent().toString()+str+\".txt\"); f.delete(); } } } } public class Example17_13 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Remember win=new Remember(); win.validate(); } }

  • 82 views
    A+
发布日期:2021年05月18日 03:08:50  所属分类:网络推广
标签: