Disallow Resizing Component with GridBagLayout in Java

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

841 Views

To disallow resizing component with GridBagLayout, use the GridBagConstraints NONE constant −GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.NONE;The following is an example to disallow resizing component with GridBagLayout −Examplepackage my; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Demo Frame");       JPanel panel = new JPanel();       GridBagLayout layout = new GridBagLayout();       panel.setLayout(layout);       GridBagConstraints gbc = new GridBagConstraints();       gbc.fill = GridBagConstraints.NONE;   ... Read More

HTML DOM Input Email Autocomplete Property

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

175 Views

The HTML DOM Input Email autocomplete property sets/returns whether autocomplete is enabled or disabled. If enabled, it shows previously typed values.SyntaxFollowing is the syntax −Returning value - on/offinputEmailObject.autocompleteSetting autocomplete to valueinputEmailObject.autocomplete = valueValuesHere, “value” can be the following −valueDetailsonIt defines that input has autocomplete enabled, it is also the default.offIt defines that input autocomplete attribute is disabled.ExampleLet us see an example of Input Email autocomplete property − Live Demo Input Email autocomplete    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       ... Read More

Print Number of Words, Vowels and Frequency of Each Character

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

330 Views

Input a string and find the total number of words, vowels and frequency of a character enter by a userInput : enter s string : I love my MOM      Enter a charcter of which you want to find a frequency: M    Total frequency of M : 2    Total number of vowels : 4    Total number of words : 4AlgorithmSTART Step 1 Declare array of string, ch, i, freq to 0, vow to 0, word to 0 Step 2 Input a string and a character ch Step 3 Loop for from i to 0 and str[i]!=’\o’ ... Read More

Change the Output of printf in Main

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

341 Views

Here we will see how to change the output of the printf() function from main(). Here we will define a function that will change all of the printf() statements with the given type to another type.We will use the #define macro to do this task. This macro will be defined inside the function. We can directly put the #define line without using it in the function, but in that case always the printf() will be changed. To control it using main, we have to call the function first.Example#include void changePrintf() { //always any printf will print 50    #define ... Read More

Find Path Between 2 Given Nodes in C++

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

317 Views

This is a C++ program to find whether a path exists between 2 given nodesAlgorithmBegin    function isReach() is a recursive function to check whether d is reachable to s:    A) Mark all the vertices as unvisited.    B) Mark the current node as visited and enqueue it and it will be used to get all adjacent vertices of a vertex.    C) Dequeue a vertex from queue and print it.    D) Get all adjacent vertices of the dequeued vertex s.    E) If an adjacent has not been visited, then mark it visited and enqueue it.   ... Read More

Maintain Top Count of Array Elements in MongoDB

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

143 Views

You can use aggregate framework. Let us first create a collection with documents −> db.topCountArrayDemo.insertOne( ...    {"StudentId":101 , "StudentSubject": ["C", "MongoDB"]} ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc6b3209cb58ca2b005e669") } > db.topCountArrayDemo.insertOne( ...    {"StudentId":102 , "StudentSubject": ["C", "Java"]} ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc6b3219cb58ca2b005e66a") } > db.topCountArrayDemo.insertOne( ...    {"StudentId":103 , "StudentSubject": ["C", "MongoDB"]} ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc6b3229cb58ca2b005e66b") }Following is the query to display all documents from a collection with the help of find() method −> db.topCountArrayDemo.find().pretty();This will produce the following output −{ ... Read More

Classic Ethernet

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

4K+ Views

Ethernet is a set of technologies and protocols that are used primarily in LANs. It was first standardized in 1980s as IEEE 802.3 standard. Ethernet is classified into two categories: classic Ethernet and switched Ethernet.Classic Ethernet is the original form of Ethernet that provides data rates between 3 to 10 Mbps. The varieties are commonly referred as 10BASE-X. Here, 10 is the maximum throughput, i.e. 10 Mbps, BASE denoted use of baseband transmission, and X is the type of medium used. Most varieties of classic Ethernet have become obsolete in present communication scenario.Varieties of Classic EthernetThe common varieties of classic ... Read More

Add Components with a Relative X Position in Java

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

641 Views

To add components with a relative X position, use the GridBagConstraints.RELATIVE constant. Set this to gridx field −GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = GridBagConstraints.RELATIVE;The following is an example to add components with a relative X position in Java −Examplepackage my; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame();       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       JPanel panel = new JPanel();       panel.setLayout(new GridBagLayout());       GridBagConstraints constraints = new GridBagConstraints();       constraints.gridy = ... Read More

Can We Declare the Method of an Interface Final in Java

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

1K+ Views

An interface in Java is a specification of method prototypes. Whenever you need to guide the programmer or, make a contract specifying how the methods and fields of a type should be you can define an interface.By default, all the methods of an interface are public and abstract. For example, In the following Java program, we are having a declaring a method with name demo.public interface MyInterface{ void demo(); }If you compile this using the javac command as shown below −c:\Examples>javac MyInterface.javait gets compiled without errors. But, if you verify the interface after compilation using the javap ... Read More

HTML DOM Option Text Property

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

155 Views

The HTML DOM option text property returns and modify the text of an option in the HTML document.SyntaxFollowing is the syntax −1. Returning textobject.text2. Modifying textobject.text = “text”ExampleLet us see an example of HTML DOM option text property − Live Demo    html{       height:100%;    }    body{       text-align:center;       color:#fff;       background: radial-gradient( circle farthest-corner at 23.1% 64.6%, rgba(129, 125, 254, 1) 0%, rgba(111, 167, 254, 1) 90% ) no-repeat;       height:100%;    }    p{       font-weight:700;       font-size:1.1rem;   ... Read More

Advertisements