Samual Sam has Published 2310 Articles

Get JFrame window size information in Java

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

3K+ Views

To get JFrame window size information, you can use the following −environment.getMaximumWindowBounds();For Screen Size −config.getBounds()For Frame Size −frame.getSize());The following is an example to get JFrame window size information −Exampleimport java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) {   ... Read More

How to set default button for JFrame in Java?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

1K+ Views

To set default button for JFrame, use the setDefaultButton() method −JFrame frame = new JFrame(); frame.getRootPane().setDefaultButton(button);The following is an example to set default button for JFrame −Exampleimport java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import javax.swing.JButton; import javax.swing.JFrame; public class SwingDemo {    public static void main(String args[]) {       ... Read More

Draw a border around an undecorated JFrame in Java

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

786 Views

At first, set an undecorated frame −setUndecorated(true);Now draw a border −getRootPane().setBorder (.createMatteBorder(3, 3, 3, 3, Color.ORANGE));The following is an example to draw a border around an undecorated JFrame −Exampleimport java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo extends JFrame {    JLabel label = ... Read More

How to get memory usage at runtime using C++?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

8K+ Views

We can get the memory usage like virtual memory usage or resident set size etc. at run time. To get them we can use some system libraries. This process depends on operating systems. For this example, we are using Linux operating system.So here we will see how to get the ... Read More

Handling large numbers in C++?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

12K+ Views

In C++, we can use large numbers by using the boost library. This C++ boost library is widely used library. This is used for different sections. It has large domain of applications. For example, using boost, we can use large number like 264 in C++.Here we will see some examples ... Read More

What is difference between instantiating a C++ object using new vs. without new?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

8K+ Views

In C++, we can instantiate the class object with or without using the new keyword. If the new keyword is not use, then it is like normal object. This will be stored at the stack section. This will be destroyed when the scope ends. But for the case when we ... Read More

How to determine the version of the C++ standard used by the compiler?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

4K+ Views

Sometimes we need to know that, what is the current C++ standard. To get this kind of information, we can use the macro called __cplusplus. For different standards, the value of this will be like below.Standard__cplusplus outputC++ pre C++981C++98199711LC++98 + TR1This cannot be checked, this will be marked as C++98C++11201103LC++14201402LC++17201703LExample#include ... Read More

How can I create directory tree using C++ in Linux?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

1K+ Views

In this section we will see how to create a directory tree using C++ code in Linux. In Linux terminal we can put some command like “mkdir –p /dir/dir1/dir2” Here –p is used to mark as parent (recursively create inner directories).In C++ code we can use some libraries of Linux ... Read More

How to check if an input is an integer using C/C++?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

4K+ Views

Here we will see how to check whether a given input is integer string or a normal string. The integer string will hold all characters that are in range 0 – 9. The solution is very simple, we will simply go through each characters one by one, and check whether ... Read More

Java Program to draw a line on a JFrame in Java

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

2K+ Views

The following is an example to draw a line on a JFrame −Examplepackage my; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Line2D; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo extends JFrame {    public SwingDemo() {       JPanel panel = new JPanel();       getContentPane().add(panel);       setSize(550, ... Read More

Advertisements