Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

How to set action command to JButton in Java

Krantik Chavan
Answered 2d 16h ago

With set action command, here we are displaying a message in the console on the click of a button.Set the button first:JButton btn = new JButton("Demo Button");Now, set Action Listener to fire when the button is clicked:ActionListener actionListener = new ActionListener() {    public void actionPerformed(ActionEvent event) {     ... Read More

How to change Button Border in Java Swing

Krantik Chavan
Answered 2d 16h ago

For Button border, use createLineBorder() method in Java, which allows you to set the color of the Border as well:JButton button = new JButton("Demo Button!"); Border border = BorderFactory.createLineBorder(Color.BLUE);The following is an example to change button border in Java:Exampleimport java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; ... Read More

How to add action listener to JButton in Java

Krantik Chavan
Answered 2d 16h ago

The following is an example to add action listener to Button:Examplepackage my; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SwingDemo {    private JFrame frame;    private JLabel headerLabel;    private JLabel statusLabel;    private JPanel controlPanel;    public SwingDemo(){       prepareGUI();    }    public static ... Read More

Can we get the supported image types in Java

Krantik Chavan
Answered 2d 16h ago

Yes, we can get the supported image types with ImageIO class in Java. The following is an example to get supported image types in Java:Examplepackage my; import javax.imageio.ImageIO; public class SwingDemo {    public static void main(String[] args) throws Exception {       String[] imgTypes = ImageIO.getReaderFileSuffixes();     ... Read More

C++ Program to Solve N-Queen Problem

Nishtha Thakur
Answered on 3rd May, 2019

This problem is to find an arrangement of N queens on a chess board, such that no queen can attack any other queens on the board.The chess queens can attack in any direction as horizontal, vertical, horizontal and diagonal way.A binary matrix is used to display the positions of N ... Read More

C++ Program to Check if a Given Set of Three Points Lie on a Single Line or Not

Smita Kapse
Answered on 3rd May, 2019

This is a C++ program to check if a given set of three points lie on a single line or not. Three points lie on a single line if the area of the triangle formed by this points is equal to zero.The area of the triangle is −0.5 * (x1 ... Read More

C++ Program to Show the Duality Transformation of Line and Point

Anvi Jain
Answered on 3rd May, 2019

This is a C++ Program to show the Duality Transformation of Line and Point. So it can have two cases −Case-1: A point (a, b) is transformed to the line (y = ax − b).Case-2: A line D(y = cx + d) is transformed to the point D’(c, −d).Functions and ... Read More

C++ program to Implement Threaded Binary Tree

Nishtha Thakur
Answered on 3rd May, 2019

Threaded binary tree is a binary tree that provides the facility to traverse the tree in a particular order.It makes inorder traversal faster and do it without stack and without recursion. There are two types of threaded binary trees.Single Threaded Each node is threaded towards either left or right means ... Read More

C++ Program to Find All Forward Edges in a Graph

Smita Kapse
Answered on 3rd May, 2019

In this section, we shall consider a C++ program to find all forward edges in a graph.AlgorithmsFor topo functionBegin    Declare function topo()       Declare pointer v, m[][5] and i of the integer datatype.       x = new Node_Inf.       x->n = i.   ... Read More

C++ Program to Check Whether Topological Sorting can be Performed in a Graph

Anvi Jain
Answered on 3rd May, 2019

In a Directed Acyclic Graph, we can sort vertices in linear order using topological sort.Topological sort is only work on Directed Acyclic Graph. In a Directed Acyclic Graph (DAG), there can be more than one topological sort.In the following C++ program, we shall perform topological sort to check existence of ... Read More

C++ Program to Check Cycle in a Graph using Topological Sort

Nishtha Thakur
Answered on 3rd May, 2019

In a Directed Acyclic Graph, we can sort vertices in linear order using topological sort.Topological sort is only work on Directed Acyclic Graph. In a Directed Acyclic Graph (DAG), there can be more than one topological sort.We shall consider a C++ program, which will perform topological sort to check cycle ... Read More

C++ Program to Check if any Graph is Possible to be Constructed for a Given Degree Sequence

Smita Kapse
Answered on 3rd May, 2019

It is a program to check possibility of construction of a graph in a given degree sequence.InputIt takes the no of edges and vertexes.OutputIt shows the random values of a created graph.AlgorithmsBegin    Declare a function RandomGraphs().       Declare NoEdge and NoVertex of the integer datatype and pass ... Read More

C++ Program to print the diamond shape

Anvi Jain
Answered on 3rd May, 2019

This is a C++ Program to print the diamond shape.AlgorithmBegin    Take the no of rows n means the dimension of the diamond shape as input.    Declare the variables i, j and initialize space=1.    Initialize space = n-1.    Run for loop till n.       Run ... Read More

C++ program to print Happy Birthday

Nishtha Thakur
Answered on 3rd May, 2019

This is a C++ program to print Happy Birthday.AlgorithmBegin    Take a str1 which takes the next character of our desired ouput like for H it will be G.    Assign the string to a pointer p.    Make a while loop till *p != NULL.       Go ... Read More

C++ program to convert time from 12 hour to 24 hour format

Smita Kapse
Answered on 3rd May, 2019

This is a C++ program to convert time from 12 hour to 24 hour format.AlgorithmBegin    In main(),    If median = pm       Check if entered hours is less than 12          Then add 12 to hours and print the time in 24 hours ... Read More

Advertisements
Loading...
Unanswered Questions View All

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.