Share on Google+Share on Google+

bhagirath singh
use of splitpane
1 Answer(s)      6 years ago
Posted in : Java Beginners

using JSplitPane split pane in three part. 1st in textField 2nd label and 3rd description. in textField we enter the primary key in textField than it show its all two part as label(image) and description of user.

thanks

Ads

View Answers

April 6, 2011 at 12:31 PM


import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;

public class SplitPane extends JFrame {
    JPanel p1 = new JPanel();
    JPanel p2 = new JPanel();
    JPanel p3 = new JPanel();

    public SplitPane() {
        p1.setLayout(null);
        p2.setLayout(null);
        p3.setLayout(null);

        final JTextField text = new JTextField(20);
        text.setBounds(5, 5, 150, 20);
        p1.add(text);

        final JLabel label = new JLabel();
        label.setBounds(5, 5, 450, 200);
        p2.add(label);

        final JTextArea area = new JTextArea(5, 20);
        JScrollPane pane = new JScrollPane(area);
        pane.setBounds(5, 5, 450, 200);
        setBounds(5, 5, 640, 450);
        p3.add(pane);
        JSplitPane sp1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);

        sp1.setDividerSize(8);

        sp1.setDividerLocation(160);

        sp1.add(p1);

        JSplitPane sp2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

        sp2.setDividerLocation(200);

        sp2.add(p2);

        sp2.add(p3);

        sp1.add(sp2);

        setContentPane(sp1);

        setVisible(true);
        text.addKeyListener(new KeyAdapter() {
            public void keyReleased(KeyEvent e) {
                area.setText("");
                try {
                    int id = Integer.parseInt(text.getText());
                    Class.forName("com.mysql.jdbc.Driver");
                    Connection con = DriverManager.getConnection(
                            "jdbc:mysql://localhost:3306/test", "root", "root");
                    Statement st = con.createStatement();
                    ResultSet rs = st
                            .executeQuery("select * from data where id=" + id
                                    + "");
                    String str = "";
                    Blob b = null;
                    while (rs.next()) {
                        str = "Name: " + rs.getString("name") + "\nAddress: "
                                + rs.getString("address") + "\nContact No: "
                                + rs.getString("contactNo");
                        b = rs.getBlob("image");
                    }
                    ImageIcon icon = new ImageIcon(b.getBytes(1L, (int) b
                            .length()));
                    label.setIcon(icon);
                    area.append(str);
                } catch (Exception ex) {
                }
            }
        });
    }

    public static void main(String[] args) {
        new SplitPane();
    }

}









Related Tutorials/Questions & Answers:
use of splitpane
use of splitpane  using JSplitPane split pane in three part. 1st in textField 2nd label and 3rd description. in textField we enter the primary key in textField than it show its all two part as label(image) and description of user
SplitPane in Java Swing
Learn SplitPane in Java Swing In this section, you will learn.... Basically this class is used to divide two components. Here splitpane... is the code Splitpane in Java Swing: import java.awt.*; import 
Advertisements
the use of ForwardAction
the use of ForwardAction  What is the use of ForwardAction
use forms.
use forms.  How do I use forms
use of annotation.
use of annotation.  for concurrency which annotation can be used
use is of 2
use is of 2  why we use 2 in "Integer.parseInt(str,2);" for binary to decimal conversion..??   ya i got it... because binary contain only two o and 1...so here use 2...same as octal has 8
Use of jQuery
Use of jQuery  What is the use of jQuery?   Hi, jQuery is JavaScript Ajax library. Developer is using it to create rich internet applications. Read at jQuery Tutorial. Thanks
use of jquery
use of jquery  what is a jquery? what is the evalution of jquery?   Hello Friend, Please visit the following link: JQuery Tutorials Thanks
Java Use cases
Java Use cases  What are use cases
How to use Servlet and Ajax?
How to use Servlet and Ajax?  How to use Servlet and Ajax
use of object tag
use of object tag  how to use object tag in html
use of ejb 3.0
use of ejb 3.0  what is use of ejb 3.0
use of return statement
use of return statement  what is the use of return statement
Use of immediate attribute
Use of immediate attribute  What is the use of immediate attribute
What is the use of friend function?
What is the use of friend function?  What is the use of friend function
What is the use of DESC in SQL?
What is the use of DESC in SQL?  What is the use of DESC in SQL
SQL Use
SQL Use       SQL Use... The Tutorial illustrate an example from 'SQL Use'. To understand and grasp the 'SQL Use' we create a database 'komal' using create database keyword
Use of FTPClient
In this section we will discuss about use of FTPClient class with example
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks
Use javax.servlet.http.HttpServletResponse object
Use javax.servlet.http.HttpServletResponse object  How do use javax.servlet.http.HttpServletResponse object to return Text data and Binary data
How to use AT Commands with J2ME?
How to use AT Commands with J2ME?  How to use AT Commands with J2ME? Thank you for your answer
use ajaxtag in Struts1.3
use ajaxtag in Struts1.3  How can use ajax tag library in jsp file in struts 1.3
use of loops and screenshots
use of loops and screenshots  1.how to use loops in netbeans? 2.how to draw a correct screenshot
use tables to structure forms
use tables to structure forms  How can I use tables to structure forms
use tables to structure forms
use tables to structure forms  How can I use tables to structure forms
Use if in velocity
Use if in velocity       This example shows you how to use if statement in velocity. Description of methods used in the example given below.... 1:- Initialize velocity run time
how to use mouse pressed
how to use mouse pressed   to action mouse clicked
how to use calender in php
how to use calender in php  how to put calender in php
What is the use of Bluetooth technology
What is the use of Bluetooth technology  What is the use of Bluetooth technology?   Bluetooth technology is used for Wireless communication between equipment's
use of ActionMapping in validate()
use of ActionMapping in validate()  why do we pass actionmapping in validate(ActionMapping mapping,HttpServletRequest) even we don't use actionmapping in that method
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads