Notes
![]() ![]() Notes - notes.io |
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
FirstFrame ff = new FirstFrame();
}
}
----------------------------------------------------
package lab3;
import javax.swing.*;
import java.awt.event.*;
public class SecondFrame extends JFrame implements ActionListener {
private JLabel txt;
private String text;
private String text1;
private JComboBox<String> combo;
private ImageIcon icon;
String [] list = { "apple", "banana", "kiwi"};
public SecondFrame(String text) {
icon= new ImageIcon("image/download.jpg");
combo = new JComboBox<>(list);
combo.setBounds(40,80,120, 30);
combo.addActionListener(this);
this.text = text;
txt = new JLabel("here : " + this.text);
txt.setBounds(40, 40, 120, 30);
this.text1 = text1;
txt.setBounds(40, 40, 500, 500);
txt.setIcon(icon);
this.add(txt);
this.add(txt);
this.add(combo);
this.setTitle("Second Frame");
this.setLayout(null);
this.setSize(400, 600);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
@Override
public void actionPerformed (ActionEvent e) {
if(e.getSource()==combo) {
if(combo.getSelectedIndex()==0) {
txt.setText(combo.getSelectedItem()+" ");
}else if(combo.getSelectedIndex()==1) {
txt.setText(combo.getSelectedItem()+" ");
}else if(combo.getSelectedIndex()==2) {
txt.setText(combo.getSelectedItem()+" ");
}
}
}
}
--------------------------------
package lab3;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class FirstFrame extends JFrame implements ActionListener {
private JTextField tf;
private JButton b;
private JCheckBox chb1, chb2, chb3;
private JTextArea ta;
private JRadioButton rb1, rb2, rb3;
private ButtonGroup bg;
public FirstFrame() {
bg = new ButtonGroup(); // groupleh
rb3 = new JRadioButton("C"); // radio button -negiig songohiin tuld buttongroup hiij ogno
rb3.setBounds(160, 320, 50, 30);
rb2 = new JRadioButton("B");
rb2.setBounds(100, 320, 50, 30);
rb1 = new JRadioButton("A", true);
rb1.setBounds(40, 320, 50, 30);
ta = new JTextArea(); // text area
ta.setBounds(40, 160, 160, 150);
chb1 = new JCheckBox("CS"); // checkbox- bugdiig n songoj bolno
chb1.setBounds(40, 120, 50, 30); // checkbox = radio button 2 adilhan zarchmaar ajillana
chb2 = new JCheckBox("IC");
chb2.setBounds(100, 120, 50, 30);
chb3 = new JCheckBox("SE");
chb3.setBounds(160, 120, 50, 30);
b = new JButton("Click"); // ehnii click button
b.setBounds(40, 80, 120, 30);
b.addActionListener(this);
tf = new JTextField(); //
tf.setBounds(40, 40, 120, 30);
chb1.addActionListener(this);
chb2.addActionListener(this);
chb3.addActionListener(this);
rb1.addActionListener(this);
rb2.addActionListener(this);
rb3.addActionListener(this);
bg.add(rb1);
bg.add(rb2);
bg.add(rb3);
this.add(rb1);
this.add(rb2);
this.add(rb3);
this.add(chb1);
this.add(chb2);
this.add(chb3);
this.add(b);
this.add(tf);
this.add(ta);
this.setLayout(null);
this.setSize(400, 600);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b) {
String txt = tf.getText();
this.dispose();
SecondFrame sf = new SecondFrame(txt);
}
if (e.getSource() == chb1) {
if (chb1.isSelected()) {
ta.append(chb1.getText() + " checked...n");
} else {
ta.append(chb1.getText() + " unchecked...n");
}
} else if (e.getSource() == chb2) {
if (chb2.isSelected()) {
ta.append(chb2.getText() + " checked...n");
} else {
ta.append(chb2.getText() + " unchecked...n");
}
} else if (e.getSource() == chb3) {
if (chb3.isSelected()) {
ta.append(chb3.getText() + " checked...n");
} else {
ta.append(chb3.getText() + " unchecked...n");
}
}
if (e.getSource() == rb1) {
if (rb1.isSelected()) {
ta.append(rb1.getText() + " checked...n");
}
} else if (e.getSource() == rb2) {
if (rb2.isSelected()) {
ta.append(rb2.getText() + " checked...n");
}
} else if (e.getSource() == rb3) {
if (rb3.isSelected()) {
ta.append(rb3.getText() + " checked...n");
}
}
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team