The following is an example to create JRadioButton from text −Examplepackage my; import java.awt.FlowLayout; import java.awt.event.KeyEvent; import javax.swing.ButtonGroup; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JRadioButton; public class SwingDemo { public static void main(String[] args) { JRadioButton radio1 = new JRadioButton("Cricket"); JRadioButton radio2 = new ... Read More
To add background image to JFrame, use the getImage() method of the Image class −Image img = Toolkit.getDefaultToolkit().getImage("E:\\rahul.jpg");Now, draw the image −public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(img, 0, 0, null); }The following is an example to add Background Image to JFrame −Exampleimport java.awt.Graphics; import java.awt.Image; import java.awt.Toolkit; ... Read More
To maximize JFrame in Java Swing, use the following −JFrame.MAXIMIZED_BOTHThe following is an example to maximize JFrame in Java −Examplepackage my; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo extends JFrame { JPanel panel = new JPanel(); public SwingDemo() { setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); ... Read More
To create a JFrame with no border and title bar, use setUndecorated() −JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(400, 300)); frame.setUndecorated(true);The following is an example to create JFrame with no border and title bar −Exampleimport java.awt.Dimension; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public ... Read More
Here, we are activating a frame. For deactivation, we have used dispose −Thread.sleep(2000); frame.setVisible(false);The frame first activates and then deactivates after 2 seconds since we have set sleep to 2000 miliseconds.The following is an example to activate and deactivate JFrame −Exampleimport java.awt.Frame; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo { ... Read More
To get directories from JFileChoose, use the mode setFileSelectionMode −JFileChooser file = new JFileChooser(); file.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);The following is an example to get Directories from JFileChooser −Exampleimport javax.swing.JFileChooser; public class SwingDemo { public static void main(String[] args) { JFileChooser file = new JFileChooser(); file.setMultiSelectionEnabled(false); ... Read More
The following is an example to display the contents of a text file in JTextArea −Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; public class SwingDemo { private JFrame mainFrame; private JLabel statusLabel; private JPanel controlPanel; public SwingDemo() { prepareGUI(); } public static ... Read More
To create FileFilter, use the FileNamExtensionFilter class. The following is an example to display File Type in JFileChooser −Exampleimport javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; public class SwingDemo { public static void main(String[] args) { JFileChooser file = new JFileChooser(); file.setAcceptAllFileFilterUsed(false); FileNameExtensionFilter extFilter ... Read More
Bit-map protocol is a collision free protocol that operates in the Medium Access Control (MAC) layer of the OSI model. It resolves any possibility of collisions while multiple stations are contending for acquiring a shared channel for transmission. In this protocol, if a station wishes to transmit, it broadcasts itself ... Read More
RSVP is a transport layer protocol that is used to reserve resources in a computer network to get different quality of services (QoS) while accessing Internet applications. It operates over Internet protocol (IP) and initiates resource reservations from the receiver’s end.FeaturesRSVP is a receiver oriented signalling protocol. The receiver initiates ... Read More
Reservation protocols are the class of protocols in which the stations wishing to transmit data broadcast themselves before actual transmission. These protocols operate in the medium access control (MAC) layer and transport layer of the OSI model.In these protocols, there is a contention period prior to transmission. In the contention ... Read More
Bit-map protocol is a collision free protocol that operates in the Medium Access Control (MAC) layer of the OSI model. It resolves any possibility of collisions while multiple stations are contending for acquiring a shared channel for transmission.In this protocol, if a station wishes to transmit, it broadcasts itself before ... Read More
In computer networks, when more than one station tries to transmit simultaneously via a shared channel, the transmitted data is garbled. This event is called collision. The Medium Access Control (MAC) layer of the OSI model is responsible for handling collision of frames. Collision – free protocols are devised so ... Read More
Here we will see the fesetround() and fegetround() method in C++. These methods can be found in the cfenv library.The fesetround() method is used to set the specified floating point rounding direction to the current rounding direction. This is used with rint(), nearbyint() and some other rounding functions in C++.The ... Read More
In C++, we can use the function overloading techniques. But if some base class has one method in overloaded form (different function signature with the same name), and the derived class redefines one of the function which is present inside the base, then all of the overloaded version of that ... Read More
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more