Add Icon to JButton in Java

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

23K+ Views

To add icon to a button, use the Icon class, which will allow you to add an image to the button.We are creating a button wherein we are adding an icon with Icon class −Icon icon = new ImageIcon("E:\editicon.PNG"); JButton button7 = new JButton(icon);Above, we have set icon for button 7.The following is an example to add icon to JButton−Examplepackage my; import javax.swing.Box; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) {       JButton button1 = new JButton("One");       JButton button2 = new JButton("Two");     ... Read More

HTML Button Value Attribute

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

757 Views

The value attribute of the element is used to set the initial value of a button. You can set this in a . Here, we will be showing an example without using a form.Following is the syntax −Above, value is the initial value.Let us now see an example to implement value attribute in −Example Live Demo Click below to get details about the learning content... Get Tutorials Get InterviewQA    function demo1() {       var val1 = document.getElementById("button1").value;       document.getElementById("myid").innerHTML = val1;    }    function demo2() {       ... Read More

8085 Program to Take All Data Except 00h from an Array

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

629 Views

Here we will see we can take all numbers which are not 00H from an array using 8085.Problem StatementWrite 8085 program to take all numbers which are not 00H from array, and store them into different location. Numbers are stored at 8001 onwards, 8000 is holding the size of array, the results will be stored from 9000.DiscussionTo solve this problem, we are taking the number from memory, then perform OR operation on the number and 00H. If the zero flag is enabled, then we can understand that the number was 00, so we just ignore that. Otherwise we just store ... Read More

Remove Non-Word Characters in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

360 Views

Removing non-word charactersTo remove non-word characters we need to use regular expressions. The logic behind removing non-word characters is that just replace the non-word characters with nothing('').ExampleIn the following example there are many non-word characters and in between them there exists a text named "Tutorix is the best e-learning platform". So using regular expressions the non-word characters were replaced with nothing('') so as to get the word characters as the output.Live Demo    function remNonWord (string) {       if ((string===null) || (string===''))       return false;       else       string = ... Read More

Display Different Variables in MySQL Using LIKE

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

158 Views

Following is the syntax −show variables where Variable_name like 'yourVariable1%' or Variable_name like 'yourVariable2%', .............N;Let us implement the above syntax to show(more than one) variables −mysql> show variables where Variable_name like 'key%' or Variable_name like 'innodb_undo%' or Variable_name like 'innodb_log%';Output+------------------------------------+----------+ | Variable_name                      | Value | +------------------------------------+----------+ | innodb_log_buffer_size             | 1048576 | | innodb_log_checksums               | ON | | innodb_log_compressed_pages        | ON ... Read More

Apply Substring for Fields in MySQL to Get Part of String

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

248 Views

You can use substring() for fields in MySQL to get part of string. Following is the syntax −select substring(yourColumnName, yourStartingIndex, yourEndingIndex) from yourTableName;Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Title longtext    ); Query OK, 0 rows affected (0.57 sec)Insert records in the table using insert command −mysql> insert into DemoTable(Title) values('MySQL is a relational database management system'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Title) values('MongoDB is a popular No SQL database'); Query OK, 1 row affected (0.18 sec)Display all records from ... Read More

Java ResultSet Last Method with Example

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

4K+ 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 last() method of the ResultSet interface moves the pointer of the current (ResultSet) object to the last row, from the current position.This method returns a boolean value specifying whether the ResultSet cursor ... Read More

Display All Deadlock Logs in MySQL

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

4K+ Views

First of all, you need to enable innodb_print_all_deadlocks. Following is the syntax −set global innodb_print_all_deadlocks=1;After executing the above statement, let us execute the below syntax in order to display all deadlock logs −show engine innodb status;Let us implement the above syntax −mysql> set global innodb_print_all_deadlocks=1; Query OK, 0 rows affected (0.00 sec) mysql> show engine innodb status;This will produce the following output −+--------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Type | Name | Status ... Read More

Set All Arrow Buttons in a Frame with Java

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

351 Views

To set arrow buttons in a frame, let us first create a frame −JFrame frame = new JFrame();Now, set the layout for the frame wherein all the arrow buttons would be displayed −frame.setLayout(new GridLayout(0, 5));Set the arrow buttons for all the locations −frame.add(new BasicArrowButton(BasicArrowButton.EAST)); frame.add(new BasicArrowButton(BasicArrowButton.NORTH)); frame.add(new BasicArrowButton(BasicArrowButton.SOUTH)); frame.add(new BasicArrowButton(BasicArrowButton.WEST));The following is an example to set all the arrow buttons in a frame −Examplepackage my; import java.awt.GridLayout; import javax.swing.Box; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.plaf.basic.BasicArrowButton; public class SwingDemo {    public static void main(String[] args) {       JButton button1 = new JButton("One");     ... Read More

Decode an Encoded String in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

11K+ Views

DecodingIn JavaScript, to decode a string unescape() method is used. This method takes a string, which is encoded by escape() method, and decodes it. The hexadecimal characters in a string will be replaced by the actual characters they represent using unescape() method.Syntaxunescape(string)ExampleIn the following the two exclamation marks have converted to hexadecimal characters using escape() method. Later on those marks were decoded in to their natural characters using unescape() method. Live Demo    // Special character encoded with escape function    var str = escape("Tutorialspoint!!");    document.write("");    document.write("Encoded : " + str);    // unescape() function    document.write("Decoded ... Read More

Advertisements