is it possible that minimizing a form will minimize another form also....??
Printable View
is it possible that minimizing a form will minimize another form also....??
If you have a reference to the other forms then it is possible to do it.
plz tell me how it is possible??
any example code will helps me better..
Plenty of example code of all sorts here: Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)
db
minizing the form will also minimize the textarea.Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
class text extends JFrame implements KeyListener
{
JPanel jp;
boolean txtChanged=false;
JTextArea t;
File file;
String fname="";
String buf="";
Container c;
text()
{
setUndecorated(true);
setVisible(true);
setResizable(true);
setLocation(550,100);
setSize(600,650);
setDefaultCloseOperation(EXIT_ON_CLOSE);
ImageIcon img=new ImageIcon("icon.png");
setIconImage(img.getImage());
jp=new JPanel();
jp.setLayout(null);
t=new JTextArea();
JScrollPane scroll=new JScrollPane(t);
t.setBorder(BorderFactory.createLineBorder(Color.black));
t.setFocusable(true);
//t.setEditable(false);
scroll.setVisible(true);
c=getContentPane();
c.setLayout(new BorderLayout());
c.add(scroll, BorderLayout.CENTER);
t.addKeyListener(this);
try
{
FileReader fr=new FileReader("intro.txt");
BufferedReader br=new BufferedReader(fr);
while ((buf=br.readLine())!=null)
{
t.append(buf);
t.append("\n");
}
br.close();
fr.close();
}
catch (IOException evt)
{
System.out.println("Exception: "+evt);
}
}
public void keyPressed(KeyEvent e)
{
//System.out.println("KP");
}
public void keyReleased(KeyEvent e)
{
//System.out.println("KR");
}
public void keyTyped(KeyEvent ke)
{
txtChanged=true;
}
}
public class array extends JFrame implements ActionListener
{
JPanel jp;
static JButton basic,operation,user_practice,menu;
JLabel bg,logo;
array()
{
super("Array-Data Structure Tutorial");
setVisible(true);
setResizable(true);
setLocation(0,0);
setSize(1200,780);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setExtendedState(JFrame.MAXIMIZED_BOTH);
//SetCrossPlatformLookAndFeel(true);
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//setDefaultLookAndFeelDecorated(true);
//UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
ImageIcon img=new ImageIcon("icon.png");
setIconImage(img.getImage());
jp=new JPanel();
jp.setBounds(0,0,500,800);
jp.setLayout(null);
basic=new JButton("Basic Terminology",new ImageIcon("basic.jpg"));
operation=new JButton("Operations",new ImageIcon("operation.jpg"));
menu=new JButton("",new ImageIcon("home.png"));
user_practice=new JButton("User Practice",new ImageIcon("user.jpg"));
bg=new JLabel(new ImageIcon("bg1.jpg"));
logo=new JLabel(new ImageIcon("logo.png"));
Font f2=new Font("calibri",Font.PLAIN,20);
Font f3=new Font("Times New Roman",Font.BOLD,15);
basic.setFont(f2);
operation.setFont(f2);
user_practice.setFont(f2);
menu.setFont(f2);
add(jp);
jp.add(basic);
jp.add(operation);
jp.add(user_practice);
jp.add(menu);
jp.add(bg);
bg.add(logo);
basic.addActionListener(this);
operation.addActionListener(this);
user_practice.addActionListener(this);
menu.addActionListener(this);
basic.setBounds(100,160,250,60);
operation.setBounds(100,260,250,60);
user_practice.setBounds(100,560,250,60);
menu.setBounds(55,30,50,50);
bg.setBounds(0,0,1300,800);
logo.setBounds(700,1,850,80);
new text();
}
public void actionPerformed(ActionEvent e)
{
/* if(e.getSource()==menu)
{
main m1=new main();
this.setVisible(false);
}
else if(e.getSource()==basic)
{
basicarray m1=new basicarray();
this.setVisible(false);
}
else if(e.getSource()==operation)
{
operations m2=new operations();
this.setVisible(false);
}
else if(e.getSource()==user_practice)
{
practicearray m4=new practicearray();
this.setVisible(false);
}*/
}
public static void main(String str[])
{
array x=new array();
}
}
plz review this code and plz run this code atleast once to understand what i want to say.....
Did you read wsaryada's response at #2?
db
yes i read that but i didn't got a solution.
That *is* the solution. If you don't understand what a reference is, and don't know how to pass a parameter to a constructor or method, stop whatever you're doing with GUIs and learn the basics first: Passing Information to a Method or a Constructor (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
db
i well understand what a reference is.
anyways thanx for the guidence db....