Create Invisible Fixed Height Component Between Two Components in Java

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

224 Views

Use the createVerticalStrut() method to create an invisible fixed height component between two components. Let’s say we have some button and we are creating a fixed height between them −box.add(button4); box.add(Box.createVerticalStrut(50)); box.add(button5); box.add(Box.createVerticalStrut(30)); box.add(button6);The following is an example to create an invisible fixed height component between two components in Java −Examplepackage my; import java.awt.BorderLayout; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JScrollPane; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Groups");       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       JButton button1 = new JButton("CSK");       JButton button2 ... Read More

Alphabetize Records and Count Duplicates in MySQL

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

197 Views

For this, use both GROUP BY and ORDER BY clause. Let us first create a table −mysql> create table DemoTable    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentGrade char(1)    ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentGrade) values('A'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(StudentGrade) values('F'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(StudentGrade) values('C'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable(StudentGrade) values('A'); Query OK, 1 row affected (0.23 sec) mysql> insert ... Read More

HTML Meta Charset Attribute

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

749 Views

The charset attribute of the element is used to specify the character encoding for the HTML document. You can use the charset attribute on as well as element.Different charsets include ASCII, ANSI, ISO-8859-1, UTF-8, etc. ISO-8859-1 supports 256 different character codes. ASCII defined 128 different alphanumeric characters. The charset attribute in HTML is used with the to specify the character encoding.Let us now see an example to implement the charset attribute of the element:Example Live Demo    Demo Heading    This is demo text.    We are learning about the charset ... Read More

Define Static Constructor in Java

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

5K+ Views

No, we cannot define a static constructor in Java, If we are trying to define a constructor with the static keyword a compile-time error will occur.In general, static means class level. A constructor will be used to assign initial values for the instance variables. Both static and constructor are different and opposite to each other. We need to assign initial values for an instance variable we can use a constructor. We need to assign static variables we can use Static Blocks.ExampleLive Demopublic class StaticConstructorTest {    int x = 10;    // Declaratiopn of Static Constructor    static StaticConstructorTest() { ... Read More

Bits Used to Represent Unicode, ASCII, UTF-16, and UTF-8 Characters in Java

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

3K+ Views

In general, data is stored in a computer in the form of bits (1 or, 0). There are various coding schemes available specifying the set of bytes represented by each character.ASCII − Stands for American Standards Code for Information Interchange. It is developed by American standards association and is the mostly used coding system. It represents characters using 7 bits and has includes 128 characters: upper and lowercase Latin alphabet, the numbers 0-9, and some extra characters).Unicode (UTF) − Stands for Unicode Translation Format. It is developed by The Unicode Consortium. if you want to create documents that use characters ... Read More

C++ Program to Find the Sum of a Series 1 + 2 + 3 + ... + n

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

2K+ Views

Here we will see how we can get the sum of the given series. The value of n will be given by user. We can solve this problem by making a factorial function, and get factorial in each step in the loop. But factorial calculation is costlier task than normal addition. We will use the previous factorial term in the next one. Like 3! is (3 * 2 * 1), and 4! is 4 * 3!. So if we store 3! into some variable, we can use that and add the next number only to get the next factorial easily.Algorithmsum_series_fact(n)begin ... Read More

HTML DOM Location Reload Method

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

340 Views

The HTML DOM Location reload() method is used for re – rendering the current document. It provides the same functionality as the reload button in the browser.SyntaxFollowing is the syntax −location.reload(forceGetParameter)ParametersHere, “forceGetParameter” can be the following −forceGetParameterDetailstrueIt defines that current document is reloaded from server.falseIt defines that current document is reloaded from browser cache.ExampleLet us see an example for Location reload() property − Live Demo Location reload()    form {       width:70%;       margin: 0 auto;    text-align: center;    }    * {       padding: 2px;       margin:5px;   ... Read More

Implementation of a Falling Matrix in C++

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

631 Views

We have seen falling matrix scene in different films etc. Here we will see how to write a C++ program to do like that.To solve this problem, we have to care about these steps.Define width of the matrixTwo successive characters may or may not have same amount of gap between themA certain amount of delay between printing each line to visualize the falling effect.Example#include #include #include #include #include #include const int wd = 70; //set the width of the matrix window const int flipsPerLine =5; //five flips for the boolean array 'alternate' const int sleepTime = 50; //it will take ... Read More

Java Connection ReleaseSavepoint Method Example

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

523 Views

A save point is a logical rollback point within a transaction. When you set a save point, whenever an error occurs past a save point, you can undo the events you have done up to the created save point using the rollback() method.You can set a save point in a database using the setSavepoint() method of the Connection interface.And, you can remove/release a save point using the releaseSavepoint() method.This method accepts a Savepoint object as a parameter and removes the specified Savepoint.To release a save point −Register the driver using the registerDriver() method of the DriverManager class as −//Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get the ... Read More

Update Array Element in MongoDB

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

250 Views

Use $addToSet operator to update array element. Let us first create a collection with documents −> db.updateArrayDemo.insertOne( ...    { ... ...       "ClientDetails" : [ ...          { ...             "ClientName" : "John", ...             "DeveloperDetails" : [ ] ...          }, ...          { ...             "ClientName" : "Larry", ...             "DeveloperDetails" : [ ] ...          } ...       ] ... ... Read More

Advertisements