Hi,
I have a frame which has tabs (code is below)--
In the Option class (given above when adding tabs) I have a textfield where user will enter text and that text will be set as title of window.private JPanel mainPane; private JFrame fr; public TabClass(){ super("change this title"); fr=new JFrame(); mainPane=new JPanel(); JTabbedPane jtp=new JTabbedPane(); this.setContentPane(mainPane); jtp.addTab("General", new General()); jtp.addTab("Options", new Options()); mainPane.add(jtp); setVisible(true); setSize(600, 600); } public static void main(String[] args) { TabClass jp=new TabClass(); }
I did not get how to set title of frame from another class. The code of Option class is as below
When I run above code a new widow is created and its title is set as text entered by user. Please tell me how to set frame title from another class? Any suggestion will also be appreciated.public void actionPerformed(ActionEvent e){ if(e.getSource()==btnSetName){ String getCompanyName=txtName.getText(); TabClass tb=new TabClass(); tb.setTitle(getCompanyName); }}