• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Java » Java

JTabbedPane Orientation in Java Example

By Dinesh Thakur

[Read more…] about JTabbedPane Orientation in Java Example

JTabbedPane Example in Java

By Dinesh Thakur

JTabbedPane : Set multiple tabbed sheets, which may contain other components. The user can select the sheet you want to see by tabs.

With the JTabbedPane class, we can have several components (usually objects JPanel) sharing the same space. The user can choose which component see selecting the tab of the desired component.

 

 

 

Create and configure a JtabbedPane

 

Method

Purpose

JTabbedPane ()
JTabbedPane (int)

Creates a tabbed pane. the argument option should appear indicating where the tabs.
By default, the tabs are in the top. You can specify these positions (as defined in the interface Swing Constants that implements
Tabbed pane): TOP, BOTTOM, LEFT, LEFT.

addTab (String, Icon, Component, String)
addTab (String, Icon, Component)
addTab (String, Component)

Add a new tab to the tabbed pane. The first argument specifies the text of the tab.
The Icon argument is optional and indicates icon tab. the argument Component specifies the component that the Tabbed pane should show when select the tab. The fourth argument, if  exists, specifies the tooltip text for tab.

 

Insert, Delete, Find and Select 

 

Method

Purpose

insertTab (String, Icon, Component, String, int)

Insert a tab at the specified index, where the first tab is at index 0. the arguments are the same as for addTab.

remove (Component)
removeTabAt (int)

Removes the tab at index or specified component.

removeAll ()

Removes all tabs.

indexOfComponent int (Component)
indexOfTab int (String)
indexOfTab int (Icon)

Returns the index of the tab that has the component, title, or icon.

setSelectedIndex void (int)
void

setSelectedComponent (Component)

Select the tab that has the index or  specified component.
Selecting a flange has the effect of
displaying its associated component.

int getSelectedIndex()

Component getSelectedComponent()

Returns the indexor component
selected tab.


Change the Appearance
 

 

Method

Purpose

void setComponentAt(int,

Component)

Component getComponentA(int)

Set or get which component is  associated with index tab Specified. The first tab is at index 0.

void setTitleAt(int, String)

String getTitleAt(int)

Set or getthe title of thetabspecified index.

void setIconAt(int, Icon)

Icon getIconAt(int)

void setDisabledIconAt(int, Icon)

Icon getDisabledIconAt(int)

Set or get icons displayed tab at the specified index.

void setBackgroundAt(int, Color)

Color getBackgroundAt(int)

void setForegroundAt(int, Color)

Color getForegroundAt(int)

Set or get the background color or Used by foreground tab index Specified. By default, a tab uses the colors of the tabbed pane.
For example, if the foreground color of Tabbed pane is black, then all The tab titles are in black, except for those which you specify another  setForegroundAt using color.

void setEnabledAt(int, boolean)

boolean isEnabledAt(int)

Set or get the activated state of the tab at the specified index.

 

import java.awt.*;
import javax.swing.*;
public class JavaExampleTabbedPaneInJApplet extends JApplet
  {
     public void init()
      {
        Container Cntnr = getContentPane();
        JTabbedPane TbdPn = new JTabbedPane();
        JPanel PnlOne = new JPanel();
        JPanel PnlTwo = new JPanel();
        JPanel PnlThree = new JPanel();
        PnlOne.add(new JLabel("This is First Panel"));
        PnlTwo.add(new JLabel("This is Second Panel"));
        PnlThree.add(new JLabel("This is Third Panel"));
        TbdPn.addTab("Tab 1",new ImageIcon("tab.jpg"),PnlOne,"This is First Tab");
        TbdPn.addTab("Tab 2", new ImageIcon("tab.jpg"),PnlTwo,"This is Second Tab");
        TbdPn.addTab("Tab three",new ImageIcon("tab.jpg"),PnlThree,"This is Third Tab");
        Cntnr.setLayout(new BorderLayout());
        Cntnr.add(TbdPn);
    }
}
/*<APPLET CODE=JavaExampleTabbedPaneInJApplet.class WIDTH=410 HEIGHT=210></APPLET>*/

JTabbedPane Example in Java

Menus and Submenus in Java Example

By Dinesh Thakur

[Read more…] about Menus and Submenus in Java Example

Stack Operation in Java Using Array Example

By Dinesh Thakur

[Read more…] about Stack Operation in Java Using Array Example

JSplitPane Java Example

By Dinesh Thakur

A split pane is a lightweight container that allows you to arrange two components (only two) side by side horizontally or vertically in a single pane. The display areas of both the components can also be adjusted at the runtime by the user. A split pane is an object of JSplitPane class.

Some of the constructors defined by JSplitPane class are as follows.

JSplitPane ()

JSpliPane(int orientation, boolean continuousLayout)

JSplitPane(int orientation, Component TopOrLeft,BottomOrRight)

JSplitPane(int orientation, boolean continuousLayout, Component TopOrLeft, Component BottomOrRight)

where,

orientation specifies how components will be arranged – can have one of the two values:

HORIZONTAL_SPLIT and VERTICAL_SPLIT

continuousLayout can have one of the two values: true,if the components are resizable

when divider is moved, otherwise false (default value)

TopOrLeft specifies the object to be placed at top or left

BottomOrRight specifies the object to be placed at bottom or right

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class JavaExampleSplitPaneInJApplet extends JApplet implements ActionListener
{
    JButton BtnTch,BtnSpltHoriz,BtnDvdrSz;
    JTextField TxtOne = new JTextField("Text Field One");
    JTextField TxtTwo = new JTextField("Text Field Two");
    JSplitPane SpltPn = new JSplitPane(JSplitPane.VERTICAL_SPLIT,TxtOne,TxtTwo);
    public void init()
      {
        Container Cntnr = getContentPane();
        JPanel Pnl = new JPanel();
        BtnTch = new JButton("One-Touch Expandable");
        BtnTch.addActionListener(this);
        Pnl.add(BtnTch);
        BtnSpltHoriz = new JButton("Horizontal Split");
        BtnSpltHoriz.addActionListener(this);
        Pnl.add(BtnSpltHoriz);
        BtnDvdrSz = new JButton("Extend Divider Size");
        BtnDvdrSz.addActionListener(this);
        Pnl.add(BtnDvdrSz);
        Cntnr.add(SpltPn, BorderLayout.CENTER);
        Cntnr.add(Pnl, BorderLayout.SOUTH);
      }
        public void actionPerformed(ActionEvent e1)
         {
            if(e1.getSource() == BtnTch)
              {
                 SpltPn.setOneTouchExpandable(true);
              }
                 if(e1.getSource() ==BtnSpltHoriz)
                {
                      SpltPn.setOrientation(SpltPn.HORIZONTAL_SPLIT);
                    }
                      if(e1.getSource() == BtnDvdrSz)
                     {
                           SpltPn.setDividerSize(SpltPn.getDividerSize() + 10);
                         }
         }
 }
/*<APPLET CODE=JavaExampleSplitPaneInJApplet.class WIDTH=610 HEIGHT=210></APPLET>*/

JSplitPane Java Example

Sound in Java Swing Example

By Dinesh Thakur

[Read more…] about Sound in Java Swing Example

Sleep Method in Thread in Java Example

By Dinesh Thakur

[Read more…] about Sleep Method in Thread in Java Example

JSeparator Event in Java Example

By Dinesh Thakur

[Read more…] about JSeparator Event in Java Example

JSeparator Java Example

By Dinesh Thakur

[Read more…] about JSeparator Java Example

Java Example Property()

By Dinesh Thakur

[Read more…] about Java Example Property()

JProgressBar Update in Java Example

By Dinesh Thakur

[Read more…] about JProgressBar Update in Java Example

JProgressBar Event in Java Example

By Dinesh Thakur

Progress bar is a user friendly control which is used to indicate the current status of some time consuming tasks such as software installation etc. It indicates the progress of a task by showing the percentage of completion using a color bar. The progress bar can be of two types namely, horizontal progress bar and vertical progress bar. In horizontal progress bar, the progress is indicated by filling the bar from left to right and in vertical progress bar, the progress is indicated by filling the bar from top to bottom. ·

A progress bar is an object of class JProgressBar which is a subclass of JComponent.

JProgressBar also implements the interface SwingConstants.

Some of the constructors defined by the JProgressBar class are as follows.

JProgressBar()

JProgressBar(int orientation)

JProgressBar(int min, int max)

JProgressBar(int orientation, int min, int max)

where,

orientation defines the orientation of the progress bar as VERTICAL or HORIZONTAL

min and max define the minimum and maximum value for the progress bar, respectively. The default values are 0 and 100

[Read more…] about JProgressBar Event in Java Example

JProgressBar Example in Java Swing

By Dinesh Thakur

JProgressBar: Displays the percentage of the total has a task to perform been completed. JProgressBar lack equivalents in the AWT. JprogressBar classes support horizontal and vertical orientations. The class is used JProgressBar  typically to show the progress of a task, such as loading an image.

The progress bar is usually set when lengthy operations are underway. It is updated periodically to update the status ofthe lengthy operation. It displays the progress of lengthy operation in terms of percentage of completion.

                      Constructors and methods of the class jProgressBar.

Constructors and Methods

Description

JProgressBar()

Constructs a horizontal progress bar without displaying progress string.

JProgressBar(int orientation)

Constructs a progress bar with the specified orientation, which can be either JProgressBar.HORIZONTAL or

JProgress Bar.VERTICAL.

jProgressBar(int min, int max)

Constructs a horizontal progress bar with specified minimum and maximum values.

JProgressBar(int orientation,int min, int max)

Constructs a progress bar with specified orientation, minimum and maximum values.

jProgressBar(BoundedRangeModel model)

Constructs a horizontal progress bar with specified model.

void addChangeListener(Change Listener I)

Adds a change listener to the progress bar

int getMaximum()

Returns the maximum value of the progress bar stored in progress bar’s BoundedRangeModel.

int getMinimum()

Returns the minimum value of the progress bar stored in progress bar’s BoundedRangeModel.

BoundedRangeModel getModel()

Returns the progress bar’s data model.

int getOrientation()

Returns the present orientation of progress bar, that is, JProgressBar.VERTICAL or JProgessBar.HORIZONTAL

int getPercentComplete()

Returns the percentage complete for the progress bar.

String getString()

Returns the current value of the progress string.

int getValue()

Returns the current value of the progress bar’s data model.

import java.awt.*;
import javax.swing.*;
public class JavaExampleProgressBarInJApplet extends JApplet
   {
     JProgressBar PrgsBar1,PrgsBar2,PrgsBar3,PrgsBar4,PrgsBar5,PrgsBar6;
     public void init()
      {
        Container Cntnr = getContentPane();
        Cntnr.setLayout(new FlowLayout());
        PrgsBar1 = new JProgressBar();
        PrgsBar1.setValue(50);
        Cntnr.add(PrgsBar1);
        PrgsBar2 = new JProgressBar();
        PrgsBar2.setMinimum(100);
        PrgsBar2.setMaximum(200);
        PrgsBar2.setValue(180);
        PrgsBar2.setForeground(Color.red);
        Cntnr.add(PrgsBar2);
        PrgsBar3 = new JProgressBar();
        PrgsBar3.setOrientation(JProgressBar.VERTICAL);
        PrgsBar3.setForeground(Color.blue);
        PrgsBar3.setValue(50);
        PrgsBar3.setStringPainted(true);
        PrgsBar3.setBorder(BorderFactory.createRaisedBevelBorder());
        Cntnr.add(PrgsBar3);
        PrgsBar4 = new JProgressBar();
        PrgsBar4.setOrientation(JProgressBar.VERTICAL);
        PrgsBar4.setForeground(Color.red);
        PrgsBar4.setValue(80);
        PrgsBar4.setStringPainted(true);
        PrgsBar4.setBorderPainted(false);
        Cntnr.add(PrgsBar4);
        PrgsBar5 = new JProgressBar();
        PrgsBar5.setOrientation(JProgressBar.VERTICAL);
        PrgsBar5.setStringPainted(true);
        PrgsBar5.setString("Welcome To Java!");
        PrgsBar5.setValue(90);
        Cntnr.add(PrgsBar5);
    }
 }
/*<APPLET CODE=JavaExampleProgressBarInJApplet.class WIDTH=500 HEIGHT=200></APPLET>*/

JProgressBar Example in Java Swing

Java Swing Plaf Componenetui

By Dinesh Thakur

[Read more…] about Java Swing Plaf Componenetui

JPasswordField Java Example

By Dinesh Thakur

[Read more…] about JPasswordField Java Example

OverLay in Java Example

By Dinesh Thakur

Overlay is a process of laying one component over another one. You can use Graphics2d to over layout one textfield component to another textfield.

import java.awt.*;
import javax.swing.*;
public class JavaExampleOverLayInJApplet extends JApplet
{
    public void init()
    {
        Container Cntnr = getContentPane();
        JPanel Pnl = new JPanel();
        Pnl.setLayout(new OverlayLayout(Pnl));
        Pnl.setBackground(Color.white);
        Pnl.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"OverLays"));
        JTextField Txt1 = new JTextField("Text One");
        JTextField Txt2 = new JTextField("Text Two");
        Txt1.setMinimumSize(new Dimension(35,35));
        Txt2.setMinimumSize(new Dimension(35,35));
        Txt1.setPreferredSize(new Dimension(110,110));
        Txt2.setPreferredSize(new Dimension(110,110));
        Txt1.setMaximumSize(new Dimension(125,125));
        Txt2.setMaximumSize(new Dimension(125,125));
        Txt1.setAlignmentX(0.3f);
        Txt1.setAlignmentY(0.3f);
        Txt2.setAlignmentX(0.9f);
        Txt2.setAlignmentY(0.9f);
        Pnl.add(Txt1);
        Pnl.add(Txt2);
        Cntnr.setLayout(new FlowLayout());
        Cntnr.add(Pnl);
    }
}
/*<APPLET  CODE =JavaExampleOverLayInJApplet.class WIDTH = 210  HEIGHT = 210 ></APPLET>*/

OverLay in Java Example

showInternalMessageDialog Example in Java

By Dinesh Thakur

[Read more…] about showInternalMessageDialog Example in Java

Java – List – Select Multiple items Example

By Dinesh Thakur

List displays a list of items. It allows the user to make multiple selections from the given list of items. The list component is added in a scroll pane, so that the long list of items is scrollable. A list is an object of JList class.

Some of the constructors defined by JList class are as follows.

JList ()

JList(Object[] listdata)

where,

listdata represents the array of Object type that displays the elements

[Read more…] about Java – List – Select Multiple items Example

JMenuItem Example in Java

By Dinesh Thakur

[Read more…] about JMenuItem Example in Java

Menu Radio Button Java Example

By Dinesh Thakur

There are several kinds of buttons in computer applications, buttons that you click on with the mouse pointer or that you activate with a key stroke. Buttons provide a way to tell the computer what to do. The buttons with the little round dots are called radio buttons, and they always come in groups of two or more. A set of radio buttons is a visual clue that you only have a choice of one of those options. Choosing another button automatically turns off the button that was currently selected, just like pressing a button on your car radio switches you from one station to the next.

Like other buttons, radio buttons are mostly found in a graphical user interface like the Macintosh or Windows or Presentation Manager, but they’re popping up in text-mode programs, too. Compare radio buttons with checkbox buttons, where you can choose as many of the checkboxes as you like.

import java.awt.*; 
import javax.swing.*;
import java.awt.event.*;
public class JavaExampleMenuRadioButtonInJApplet extends JApplet implements ItemListener
     {
        ImageIcon Icn = new ImageIcon("item.jpg");
        JRadioButtonMenuItem
        RdoBtnMnuItem1 = new JRadioButtonMenuItem("Item 1", Icn),
        RdoBtnMnuItem2 = new JRadioButtonMenuItem("Item 2", Icn),
        RdoBtnMnuItem3 = new JRadioButtonMenuItem("Item 3", Icn),
        RdoBtnMnuItem4 = new JRadioButtonMenuItem("Item 4", Icn);
        public void init()
         {
             Container Cntnr = getContentPane();
             JMenuBar MnuBar = new JMenuBar();
             JMenu Mnu = new JMenu("Radio Button Menu Items");
             Mnu.add(RdoBtnMnuItem1);
             Mnu.add(RdoBtnMnuItem2);
             Mnu.add(RdoBtnMnuItem3);
             Mnu.add(RdoBtnMnuItem4);
             ButtonGroup BtnGrp = new ButtonGroup();
             BtnGrp.add(RdoBtnMnuItem1);
             BtnGrp.add(RdoBtnMnuItem2);
             BtnGrp.add(RdoBtnMnuItem3);
             BtnGrp.add(RdoBtnMnuItem4);
             RdoBtnMnuItem1.addItemListener(this);
             RdoBtnMnuItem2.addItemListener(this);
             RdoBtnMnuItem3.addItemListener(this);
             RdoBtnMnuItem4.addItemListener(this);
             MnuBar.add(Mnu);
             setJMenuBar(MnuBar);
         }
             public void itemStateChanged(ItemEvent e1)
              {
                 JMenuItem MnuItem= (JMenuItem) e1.getSource();
                 String ItmTxt = MnuItem.getText();
                 if(e1.getStateChange() == ItemEvent.SELECTED)
                 ItmTxt += " was selected";
                 else
                 ItmTxt += " was deselected";
             showStatus(ItmTxt);
              }
  }
/*<APPLET CODE = JavaExampleMenuRadioButtonInJApplet.class WIDTH = 350 HEIGHT = 280 ></APPLET>*/

Menu Radio Button Java Example

Java – Add Icon to Menu Item Example

By Dinesh Thakur

[Read more…] about Java – Add Icon to Menu Item Example

Disable Menuitem in Java Swing Example

By Dinesh Thakur

[Read more…] about Disable Menuitem in Java Swing Example

Menu Control in Java Swing Example

By Dinesh Thakur

We understand all upper menu structure of a graphical application that allows us to display a list of operations that in turn can contain other lists of operations. The basic structure consists of a menu JMenuBar (the top bar) from which dangle (JMenu) menus that we add elements (JMenuItem) that can be JCheckBoxMenuItem, and even JRadioButtonMenuItem JMenu. Consider now the methods of each of these classes:

JMenuBar:

public JMenuBar (): creates a new JMenuBar;
public JMenu add (JMenu m): add a JMenu to the MenuBar;
GetMenu public JMenu (int index): Returns the index associated with the corresponding menu.

 

JMenuItem (JCheckBoxMenuItem superclass, and JradioButtonItem JMenu):
public JMenuItem () creates an empty menu item;
public JMenuItem (String text) creates a string associated;
public JMenuItem (Icon icon) is created with an associated image that will be displayed in the menu;
public void setEnabled (boolean b) indicate whether we want or not can be selected.

 

JMenu:


public JMenu (String s) Creates a new JMenu that displays the specified string;
public JMenu add (JMenuItem menuItem): adds the JMenu JMenuItem;
public JMenu add (String s) Creates a new menu item with the specified text and puts it at the end of this JMenu;
public void addSeparator () adds a separating horizontal line;
public JMenuItem getItem (int pos): Returns the JMenuItem containing the indicated position
 

import java.awt.*; 
import javax.swing.*;
import java.awt.event.*;
public class JavaExampleMenuControlInJApplet extends JApplet implements ActionListener
{
    public void init()
     {
        JMenuBar MnuBar = new JMenuBar();
        JMenu MnuOne = new JMenu("File");
        JMenuItem MnuItmOne = new JMenuItem("New..."),
        MnuItmTwo = new JMenuItem("Open..."),
        MnuItmThree = new JMenuItem("Exit");
        JButton BtnPrss = new JButton("Prees Here!");
        BtnPrss.setActionCommand("You Pressed the Button");
        BtnPrss.addActionListener(this);
        MnuOne.add(MnuItmOne);
        MnuOne.add(MnuItmTwo);
        MnuOne.addSeparator();
        MnuOne.add(BtnPrss);
        MnuOne.addSeparator();
        MnuOne.add(MnuItmThree);
        JMenu MnuTwo = new JMenu("Edit");
        JMenuItem MnuItmFour = new JMenuItem("Cut"),
        MnuItmFive = new JMenuItem("Copy"),
        MnuItmSix = new JMenuItem("Paste");
        MnuTwo.add(MnuItmFour);
        MnuTwo.add(MnuItmFive);
        MnuTwo.add(MnuItmSix);
        MnuBar.add(MnuOne);
        MnuBar.add(MnuTwo);
        setJMenuBar(MnuBar);
     }
        public void actionPerformed(ActionEvent e1)
         {
            JButton Btn = (JButton)e1.getSource();
            showStatus(Btn.getActionCommand());
        }
 }
/*<APPLET CODE=JavaExampleMenuControlInJApplet.class  WIDTH = 350  HEIGHT = 280 ></APPLET>*/

Menu Control in Java Swing Example

MenuAccelerator in Java example

By Dinesh Thakur

[Read more…] about MenuAccelerator in Java example

Java MediaTracker Example

By Dinesh Thakur

The java.awt.MediaTracker class is a useful class.It can monitor the progress of any number of images, so you can expect to all images are loaded or to be loaded only specific. Furthermore, can check for errors. The constructor is: public MediaTracker (Component comp) This constructor creates a new MediaTracker for pictures to be displayed in the variable comp, but really this parameter is not particularly important. 

To upload images, a MediaTracker object provides the method following :
public void addImage ( Image image , int id)
This method adds the thumbnail image to the image list to load the object MediaTracker receiving the message . The id variable is used as the number of image identification when using other methods concerning this class.

import java.awt.*; 
import java.applet.*;
public class JavaExampleMediaTrackerInJavaApplet extends Applet
{
    Image Img;
    public void init()
     {
        MediaTracker Trckr = new MediaTracker(this);
        Img = getImage(getDocumentBase(),"Koala.jpg");
        Trckr.addImage(Img,0);
        try
           {
              Trckr.waitForAll();
           }
            catch (InterruptedException e1) { }
     }
            public void paint(Graphics gr)
             {
               gr.drawImage(Img, 10, 10, this);
             }
}
/*<APPLET CODE=JavaExampleMediaTrackerInJavaApplet.class WIDTH=600 HEIGHT=150> </APPLET>*/

Java MediaTracker Example

ListMultiple in Java Swing Example

By Dinesh Thakur

[Read more…] about ListMultiple in Java Swing Example

ListIterator Java Example

By Dinesh Thakur

[Read more…] about ListIterator Java Example

Java – Add an image to a JList item

By Dinesh Thakur

JList: The JList is a list on which we can view and select more than one item simultaneously. In case there are more items than can be simultaneously displayed due to the size of the list, a vertical scroll bar appears. Relevant methods:

 

public JList () Creates an empty JList;
public JList (Object [] listaItems) created with the items contained in the array of objects;
public JList (Vector listaItems) created with the Vector elements;
getSelectedIndex public int (): returns the index of the first selected item (-1 if none);
public int [] getSelectedIndices (): returns an array of indices that are selected;
getSelectedValue public Object () gives the reference to the object;
public Object [] getSelectedValues ​​(): returns an array of Object
selected.

 

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class JavaExampleListImageInJApplet extends JApplet
{
    public void init()
    {
        Container Cntnr = getContentPane();
        newModel NwModl = new newModel();
        newRenderer NwRndrer = new newRenderer();
        JList Lst = new JList(NwModl);
        Lst.setCellRenderer(NwRndrer);
        Lst.setVisibleRowCount(5);
        Cntnr.add(new JScrollPane(Lst));
    }
}
      class newModel extends DefaultListModel
       {
           public newModel()
           {
               for(int loop_indx = 0; loop_indx <= 10; loop_indx++)
                    {
                       addElement(new Object[] {"ITEM :" + loop_indx,new ImageIcon("Koala.jpg")});
                    }
           }
       }
             class newRenderer extends JLabel implements ListCellRenderer
               {
                  public newRenderer()
                    {
                       setOpaque(true);
                    }
                       public Component getListCellRendererComponent(JList JLst, Object ob1, int indx, boolean isSelected,boolean Focus)
                         {
                             newModel Mdl = (newModel)JLst.getModel();
                             setText((String)((Object[])ob1)[0]);
                             setIcon((Icon)((Object[])ob1)[1]);
                             if(!isSelected)
                          {
                                 setBackground(JLst.getBackground());
                                setForeground(JLst.getForeground());
                              }
                                else
                            {
                                        setBackground(JLst.getSelectionBackground());
                                        setForeground(JLst.getSelectionForeground());
                                    }
                                        return this;
                          }
                }
/*<APPLET CODE=JavaExampleListImageInJApplet.class WIDTH=310 HEIGHT=310 ></APPLET>*/

Java - Add an image to a JList item

DoubleList Java Example

By Dinesh Thakur

[Read more…] about DoubleList Java Example

LinkedList Java Example

By Dinesh Thakur

[Read more…] about LinkedList Java Example

« Previous Page
Next Page »

Primary Sidebar

Java Tutorials

Java Tutorials

  • Java - Home
  • Java - IDE
  • Java - Features
  • Java - History
  • Java - this Keyword
  • Java - Tokens
  • Java - Jump Statements
  • Java - Control Statements
  • Java - Literals
  • Java - Data Types
  • Java - Type Casting
  • Java - Constant
  • Java - Differences
  • Java - Keyword
  • Java - Static Keyword
  • Java - Variable Scope
  • Java - Identifiers
  • Java - Nested For Loop
  • Java - Vector
  • Java - Type Conversion Vs Casting
  • Java - Access Protection
  • Java - Implicit Type Conversion
  • Java - Type Casting
  • Java - Call by Value Vs Reference
  • Java - Collections
  • Java - Garbage Collection
  • Java - Scanner Class
  • Java - this Keyword
  • Java - Final Keyword
  • Java - Access Modifiers
  • Java - Design Patterns in Java

OOPS Concepts

  • Java - OOPS Concepts
  • Java - Characteristics of OOP
  • Java - OOPS Benefits
  • Java - Procedural Vs OOP's
  • Java - Polymorphism
  • Java - Encapsulation
  • Java - Multithreading
  • Java - Serialization

Java Operator & Types

  • Java - Operator
  • Java - Logical Operators
  • Java - Conditional Operator
  • Java - Assignment Operator
  • Java - Shift Operators
  • Java - Bitwise Complement Operator

Java Constructor & Types

  • Java - Constructor
  • Java - Copy Constructor
  • Java - String Constructors
  • Java - Parameterized Constructor

Java Array

  • Java - Array
  • Java - Accessing Array Elements
  • Java - ArrayList
  • Java - Passing Arrays to Methods
  • Java - Wrapper Class
  • Java - Singleton Class
  • Java - Access Specifiers
  • Java - Substring

Java Inheritance & Interfaces

  • Java - Inheritance
  • Java - Multilevel Inheritance
  • Java - Single Inheritance
  • Java - Abstract Class
  • Java - Abstraction
  • Java - Interfaces
  • Java - Extending Interfaces
  • Java - Method Overriding
  • Java - Method Overloading
  • Java - Super Keyword
  • Java - Multiple Inheritance

Exception Handling Tutorials

  • Java - Exception Handling
  • Java - Exception-Handling Advantages
  • Java - Final, Finally and Finalize

Data Structures

  • Java - Data Structures
  • Java - Bubble Sort

Advance Java

  • Java - Applet Life Cycle
  • Java - Applet Explaination
  • Java - Thread Model
  • Java - RMI Architecture
  • Java - Applet
  • Java - Swing Features
  • Java - Choice and list Control
  • Java - JFrame with Multiple JPanels
  • Java - Java Adapter Classes
  • Java - AWT Vs Swing
  • Java - Checkbox
  • Java - Byte Stream Classes
  • Java - Character Stream Classes
  • Java - Change Color of Applet
  • Java - Passing Parameters
  • Java - Html Applet Tag
  • Java - JComboBox
  • Java - CardLayout
  • Java - Keyboard Events
  • Java - Applet Run From CLI
  • Java - Applet Update Method
  • Java - Applet Display Methods
  • Java - Event Handling
  • Java - Scrollbar
  • Java - JFrame ContentPane Layout
  • Java - Class Rectangle
  • Java - Event Handling Model

Java programs

  • Java - Armstrong Number
  • Java - Program Structure
  • Java - Java Programs Types
  • Java - Font Class
  • Java - repaint()
  • Java - Thread Priority
  • Java - 1D Array
  • Java - 3x3 Matrix
  • Java - drawline()
  • Java - Prime Number Program
  • Java - Copy Data
  • Java - Calculate Area of Rectangle
  • Java - Strong Number Program
  • Java - Swap Elements of an Array
  • Java - Parameterized Constructor
  • Java - ActionListener
  • Java - Print Number
  • Java - Find Average Program
  • Java - Simple and Compound Interest
  • Java - Area of Rectangle
  • Java - Default Constructor Program
  • Java - Single Inheritance Program
  • Java - Array of Objects
  • Java - Passing 2D Array
  • Java - Compute the Bill
  • Java - BufferedReader Example
  • Java - Sum of First N Number
  • Java - Check Number
  • Java - Sum of Two 3x3 Matrices
  • Java - Calculate Circumference
  • Java - Perfect Number Program
  • Java - Factorial Program
  • Java - Reverse a String

Other Links

  • Java - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW