Create Rounded Borders in Swing

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

6K+ Views

Let us first create a Frame:JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setUndecorated(true);Now, create rounded borders:double x = 50; double y = 50; frame.setShape(new RoundRectangle2D.Double(x, y, 100, 100, 50, 50));The following is an example to create rounded borders in Swing:Exampleimport java.awt.geom.RoundRectangle2D; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo extends JPanel {    public static void main(String[] args) {       JFrame frame = new JFrame();       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       frame.setUndecorated(true);       double x = 50;       double y = 50;       frame.setShape(new RoundRectangle2D.Double(x, y, 100, 100, 50, 50));     ... Read More

Java SQL Date valueOf Method with Example

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

4K+ Views

The valueOf() method of the java.sql.Date class accepts a String value representing a date in JDBC escape format (yyyy-mm-dd) and convertsthe given String value into Date object.Date date = Date.valueOf("date_string");ExampleLet us create a table with name dispatches in MySQL database using CREATE statement as follows −CREATE TABLE dispatches(    ProductName VARCHAR(255),    CustomerName VARCHAR(255),    DispatchDate date,    DeliveryTime time,    Price INT,    Location VARCHAR(255));Now, we will insert 5 records in dispatches table using INSERT statements −insert into dispatches values('Key-Board', 'Raja', DATE('2019-09-01'), TIME('11:00:00'), 7000, 'Hyderabad'); insert into dispatches values('Earphones', 'Roja', DATE('2019-05-01'), TIME('11:00:00'), 2000, 'Vishakhapatnam'); insert into dispatches values('Mouse', 'Puja', ... Read More

Perform Mathematical Operations in MySQL Using IF-THEN-ELSE

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

289 Views

For performing mathematical operations and working with conditions, you can consider CASE statement. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FruitName varchar(100),    FruitPrice int    ); Query OK, 0 rows affected (0.26 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FruitName, FruitPrice) values('Orange', 250); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(FruitName, FruitPrice) values('Banana', 100); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(FruitName, FruitPrice) values('Apple', 150); Query OK, 1 row affected (0.05 sec) ... Read More

Add Manifest Permission to an Application in Android

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

633 Views

This example demonstrate about How to add manifest permission to an application in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;       setContentView(R.layout. activity_main ) ;    } }Step 4 − Add the following ... Read More

Creating an Index on a Nested MongoDB Field

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

2K+ Views

You can use dot(.) notation for this. Let us first create a collection with documents −> db.createIndexOnNestedFieldDemo.insertOne(    {"UserDetails":{"UserPersonalDetails":{"UserFirstName":"John", "UserLastName":"Smith"}}});    {       "acknowledged" : true,       "insertedId" : ObjectId("5ce929c778f00858fb12e916")    } > > db.createIndexOnNestedFieldDemo.insertOne( {"UserDetails":{"UserPersonalDetails":{"UserFirstName":"Chris", "UserLastName":"Brown"}}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce929d678f00858fb12e917") } > db.createIndexOnNestedFieldDemo.insertOne( {"UserDetails":{"UserPersonalDetails":{"UserFirstName":"David", "UserLastName":"Miller"}}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce929e378f00858fb12e918") }Following is the query to display all documents from a collection with the help of find() method −> db.createIndexOnNestedFieldDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5ce929c778f00858fb12e916"),    "UserDetails" : {       ... Read More

Return Query Results in Same Order as Values in MySQL IN Statement

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

239 Views

Yes, you can achieve this with ORDER BY FIELD() from MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(19); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(34); Query OK, 1 row affected (0.32 sec) mysql> insert into DemoTable values(28); Query OK, 1 row ... Read More

HTML DOM Input Week Disabled Property

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

117 Views

The Input Week disabled property sets/returns whether Input Week is enabled or disabled.SyntaxFollowing is the syntax −Returning boolean value - true/falseinputWeekObject.disabledSetting disabled to booleanValueinputWeekObject.disabled = booleanValueBoolean ValuesHere, “booleanValue” can be the following −booleanValueDetailsTrueIt defines that the input week is disabled.FalseIt defines that the input week is not disabled and it is also the default value.ExampleLet us see an example for Input Week disabled property − Live Demo Input Week Disabled    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;   ... Read More

Add Data to Existing Data in a MySQL Database

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

816 Views

You can use CONCAT() function for this. Let us first create a table −mysql> create table DemoTable    (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserName varchar(100)    ); Query OK, 0 rows affected (0.43 sec)Insert records in the table using insert command −mysql> insert into DemoTable(UserName) values('John'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable(UserName) values('Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(UserName) values('Robert'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+--------+----------+ ... Read More

MySQL Query to Select Row with Same Number in Column

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

148 Views

You need to use FIND_IN_SET() for this. Let us first create a table −mysql> create table DemoTable ( CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(20), CustomerAllProductPrice text ); Query OK, 0 rows affected (0.30 sec)Insert some records in the table using insert command. Here, we are inserting numbers separated by comma −mysql> insert into DemoTable(CustomerName, CustomerAllProductPrice) values('Chris', '245, 345, 678, 90, 45, 56, 78'); Query OK, 1 row affected (0.03 sec) mysql> insert into DemoTable(CustomerName, CustomerAllProductPrice) values('Chris', '98, 99, 90, 56, 77'); ... Read More

Get Leaf After Node in JTree Component with Java

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

180 Views

Use the getNextLeaf() method to get the leaf after this node in a JTree. Here, we are displaying the leaf after node “three” in Console −System.out.println("Next leaf after this node = "+three.getNextLeaf());The following is an example to get the leaf node after this node in a JTree component −package my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Demo");       DefaultMutableTreeNode node = new DefaultMutableTreeNode("Products");       DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Clothing (Product1 - P66778)");       DefaultMutableTreeNode ... Read More

Advertisements