Work with Border Layout Position Options in Java

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

316 Views

Let us see some examples to work with different border layout position options such as PAGE_START, PAGE_END, etc.The following is an example of BorderLayout.PAGE_START option −Examplepackage my; import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JToolBar; public class SwingDemo {    public static void main(String[] args) {       JPanel panel = new JPanel(new BorderLayout());       JToolBar toolbar = new JToolBar();       panel.add(toolbar, BorderLayout.PAGE_START);       toolbar.add(new JTextArea(" Add name here"));       toolbar.add(new JButton("Submit Name"));       toolbar.addSeparator();       toolbar.add(new JTextArea(" Add age here"));     ... Read More

Subtract Two Consecutive Bytes of an Array in 8085

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

304 Views

Here we will see how we can subtract two consecutive elements in an array using 8085.Problem StatementWrite 8085 program to subtract two consecutive elements of an array and store them in the same location. The results will be placed at the same location from where they are taken. The numbers are stored from location 8001. The size of array is stored at 8000.DiscussionHere we will solve this problem by using one subroutine. That will subtract two consecutive numbers and stored them into correct position. That subroutine will be called multiple times to subtract all consecutive pairs. The task will be ... Read More

Select Any One Field Out of Two Based on a Third Field in MySQL

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

75 Views

For this, use IF(). Let us first create a table −mysql> create table DemoTable    -> (    -> PlayerName varchar(100),    -> PlayerScore int,    -> PlayerStatus varchar(100)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John', 88, 'BAD'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Chris', 78, 'BAD'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('Robert', 90, 'BAD'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('David', 80, 'BAD'); Query ... Read More

HTML DOM Input Button Type Property

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

188 Views

The HTML DOM input button type property returns the type of the input button i.e. whether it is of “button”, “submit” or “reset” type.SyntaxFollowing is the syntax −object.typeExampleLet us see an example of input button type property − Live Demo HTML DOM type Property    body{       text-align:center;    }    .btn{       display:block;       margin:1rem auto;       background-color:#db133a;       color:#fff;       border:1px solid #db133a;       padding:0.5rem;       border-radius:50px;       width:40%;    }    .show-type{       font-weight:bold;   ... Read More

HTML DOM Input datetime-local min Property

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

174 Views

The HTML DOM Input DatetimeLocal min property returns/sets min attribute of Input DatetimeLocal.SyntaxFollowing is the syntax −Returning string valueinputDatetimeLocalObject.minSetting min to string valueinputDatetimeLocalObject.min = YYYY-MM-DDThh:mm:ssString ValuesHere, “YYYY-MM-DDThh:mm:ss” can be the following −stringValueDetailsYYYYIt defines year (eg:199)MMIt defines month (eg: 07 for July)DDIt defines Day (eg: 11)TIt is a separator for date and timehhIt defines hour (eg:08)mmIt defines minutes (eg:18)ssIt defines seconds (eg:23)ExampleLet us see an example of Input DatetimeLocal min property − Live Demo Input DatetimeLocal min    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * ... Read More

HTML DOM KeyboardEvent charCode Property

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

124 Views

The KeyboardEvent charCode property returns the unicode character codes corresponding to character that was pressed using an event.Note − Use key property instead for accurate resultsSyntaxFollowing is the syntax −Returning latest typed character’s charCode −event.charCodeExampleLet us see an example for KeyboardEvent charCode property − Live Demo KeyboardEvent charCode    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } KeyboardEvent-charCode Fill ... Read More

Which One is Better: POW or POWER in MySQL

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

185 Views

Both pow() and power() are synonyms in MySQL. Following is the syntax −select pow(yourValue1, yourValue2); OR select power(yourValue1, yourValue2);Let us implement both the above syntaxes.Using POW()mysql> select POW(4, 3);This will produce the following output −+----------+ | POW(4, 3) | +----------+ | 64 | +----------+ 1 row in set (0.00 sec)Using POWER()mysql> select POWER(4, 3);This will produce the following output −+------------+ | POWER(4, 3) | +------------+ | 64 | +------------+ 1 row in set (0.00 sec)Let us implement the above syntax in a table −mysql> create table ... Read More

Java ResultSet getMetaData Method with Example

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

7K+ Views

When we execute certain SQL queries (SELECT query in general) they return tabular data.The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.The ResultSetMetaData provides information about the obtained ResultSet object like, the number of columns, names of the columns, datatypes of the columns, name of the table etc…The getMetaData() method of ResultSet interface ... Read More

Select Last 3 Rows from Database Order by ID Asc

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

465 Views

You can use subquery. Following is the syntax −SELECT * FROM (    SELECT * FROM yourTableName ORDER BY yourIdColumnName DESC LIMIT 3 ) anyAliasName ORDER BY yourIdColumnName;Let us first create a table −mysql> create table DemoTable (    ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientName varchar(100) ); Query OK,  0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ClientName) values('Larry'); Query OK,  1 row affected (0.18 sec) mysql> insert into DemoTable(ClientName) values('Chris'); Query OK,  1 row affected (0.12 sec) mysql> insert into DemoTable(ClientName) values('Bob'); Query OK,  1 row affected (0.10 sec) mysql> insert into DemoTable(ClientName) values('David'); Query OK,  1 row affected (0.12 sec) mysql> insert into DemoTable(ClientName) values('Carol'); Query OK,  1 row affected (0.10 sec) mysql> insert into DemoTable(ClientName) values('Robert'); Query OK,  1 row affected (0.19 sec) mysql> insert into DemoTable(ClientName) values('Sam'); Query OK,  1 row affected (0.17 sec) mysql> insert into DemoTable(ClientName) values('Mike'); Query OK,  1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce ... Read More

Create a Layout Using GridBagLayout in Java

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

250 Views

The GridBagLayout creates a grid bag layout manager. It arranges the components in a horizontal and vertical manner.Here, we have a frame and panel. The panel has two components arranged using GridBagLayout −JFrame frame = new JFrame("Demo Frame"); JPanel panel = new JPanel(); JLabel label = new JLabel("Email-Id: "); JTextArea text = new JTextArea(); text.setText("Add id here..."); panel.setLayout(new GridBagLayout());Now, set the components to the panel −panel.add(label); panel.add(text);The following is an example to create a layout using GridBagLayout −Examplepackage my; import java.awt.GridBagLayout; import javax.swing.BorderFactory; 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 ... Read More

Advertisements