Joption pane

Joption pane

View Answers

December 3, 2008 at 5:12 AM

Hi friend,

Code to solve the problem :


class InsertWord
{
public static String insertWord(String sentence, String word, int position)
{
String sentenceAr[] = sentence.split(" ");
String strAr[] = new String[sentenceAr.length+1];
String stringResult=" ";
if(position==0)
{
System.out.println("position : " + position);
strAr[0] = word;
stringResult +=" "+strAr[0];
for(int i=1;i<strAr.length;i++)
{
strAr[i] =sentenceAr[i-1];
stringResult +=" "+ strAr[i] + " ";
}
}
else if(position!=0)
{

for(int i=0;i<position;i++)
{
strAr[i] =sentenceAr[i];
stringResult +=" "+ strAr[i];
}
strAr[position] =word;
stringResult +=" "+ strAr[position];
for(int i=position+1;i<strAr.length;i++)
{
strAr[i] =sentenceAr[i-1];
stringResult +=" "+ strAr[i];
}
}


return stringResult;

}
public static void main(String[] args)
{
String sentence ="Hello World";
String word ="Roseindia";
int position = -1;
String sentenceAr[] = sentence.split(" ");
if(!(position>sentenceAr.length || position<0))
System.out.println(insertWord(sentence, word, position));
else
System.out.println(sentence);
}
}

Thanks









Related Tutorials/Questions & Answers:
Joption pane - Java Beginners
Joption pane  The problem A sentence can be thought of as one or more words which are delimited by spaces. For example: ?A sentence is constructed with a series of words? The first word is ?A? The second word is ?sentence
accordion pane - Ajax
accordion pane  Is it possible to change the content of an accordion pane promgramatically? I wrote : function modif_pane1(){ dijit.layout.byId("pane1").content="string"; } but that's don't work
Advertisements
how to send joption panel dialog from server to multipleclients using sockets?
how to send joption panel dialog from server to multipleclients using sockets?  how to send joption panel dialog from server to multipleclients using sockets?like we get a first message with 2 buttonsand on clicking one button we
how to send joption panel dialog from server to multipleclients using sockets?
how to send joption panel dialog from server to multipleclients using sockets?  how to send joption panel dialog from server to multipleclients using sockets?like we get a first message with 2 buttonsand on clicking one button we
how to send joption panel dialog from server to multipleclients using sockets?
how to send joption panel dialog from server to multipleclients using sockets?  how to send joption panel dialog from server to multipleclients using sockets?like we get a first message with 2 buttonsand on clicking one button we
Java scroll pane-java GUI
Java scroll pane-java GUI  Dear friends.. Very Good morning. I have a doubt in my gui application. Take ex:- My gui application has 1 Jscrollpane of height 600 and width 400. normally it is showing 200 height and 400 width
ModuleNotFoundError: No module named 'dash-split-pane'
ModuleNotFoundError: No module named 'dash-split-pane'  Hi, My... named 'dash-split-pane' How to remove the ModuleNotFoundError: No module named 'dash-split-pane' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'dash-split-pane'
ModuleNotFoundError: No module named 'dash-split-pane'  Hi, My... named 'dash-split-pane' How to remove the ModuleNotFoundError: No module named 'dash-split-pane' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'dash-split-pane'
ModuleNotFoundError: No module named 'dash-split-pane'  Hi, My... named 'dash-split-pane' How to remove the ModuleNotFoundError: No module named 'dash-split-pane' error? Thanks   Hi, In your python
how add tabs at the left side of a pane
how add tabs at the left side of a pane  sir i have added the tabs at the top left corner of the pane, but i am unable to add it at the left side of the pane, so please help me
Create a Desktop Pane Container in Java
Create a Desktop Pane Container in Java   ... pane container in Java. The desktop pane container is a container, which has.... The desktop pane is like a MDI (Multiple Document Interface) frame and all internal
Create a Scroll Pane Container in Java
Create a Scroll Pane Container in Java   ... to create a scroll pane container in Java Swing. When you simply create a Text Area... a scroll pane for the given text area. The following methods and APIs used
problem in adding a fullscreen frame nd adding a glass pane to it
problem in adding a fullscreen frame nd adding a glass pane to it  hi , here is my code import java.awt.*; import javax.swing.*; import...(){ setTitle("glass pane"); Dimension d=ToolKit.getDefaultToolKit().getScreenSize
Set the Color of a Tab in a Tabbed Pane Container in Java
Set the Color of a Tab in a Tabbed Pane Container in Java... will learn how to set colors for a tab in a tabbed pane container in Java Swing... This program shows you how to set the color for each tab in the tabbed pane
java gui-with jscroll pane
java gui-with jscroll pane
JTABLE SCROLL PANE
JTABLE SCROLL PANE
Freeze And Split Pane
freeze and split pane     ... sheets, we use  freeze the pane in different ways and in last one we split...,topRow  for the top row visible in bottom pane and leftmostColumn 
Excel Splits Pane Feature
Excel Splits Pane Feature In this section, you will learn how to split... of the sheet. This can be done using Excel Splits Pane Feature. Using... is the y position of the split. The last parameter indicates which pane currently
Excel Freeze Pane Feature
Excel Freeze Pane Feature In this section, you will learn about freezing row of excel document using Apache POI library. Sometimes when you scroll down too... which cell belongs to which heading. The solution of this problem is Freeze Pane
Java JTabbedPane Example
Java JTabbedPane Example In this section we will discuss about how to add the Tab pane in JFrame. javax.swing.JTabbedPane provides the feature to add tabs...); vegetable.add(lab8); tp=new JTabbedPane(); Container pane
SplitPane in Java Swing
Learn SplitPane in Java Swing In this section, you will learn how to create split pane using java swing. For this, we have used JSplitPane class. Basically this class is used to divide two components. Here splitpane
Simple input application in Echo3
a text and this value would be shown into the content pane when user will click
Tomahawk pannelTabbedPane tag
to create a tabbed pane. Its has the capability of switching the tabs at client..._panelTabbedPane_activeHeaderCell input, #_idJsp0 .myFaces_panelTabbedPane_pane
Java prog - Java Beginners
Java prog  Write a program on Java that ask the user to input: Cost of Machine, Life of Machine, Cost of capital in Percentage, in an JOption pane... as ur requirement. import javax.swing.JOptionPane; public class JOption
java programming - Java Beginners
java programming  I need a java program that will add,edit,delete,view,save and print any information..it could be a JOption application..tnx  Hi Friend, Do you want to use database?Please clarify this. Thanks
jtabbedpane
jtabbedpane  how to add a close button in jtabbed pane using java swing
jsplitpane - Java Beginners
jsplitpane  Hi, I need the example code for jsplitpane. I have divided into two splitpanes,while i am click the left side pane text or button... side pane "using JPanel". Please send the code as soon as possible. Thanks
jsplitpane - Java Beginners
jsplitpane  Hi, I need the example code for jsplitpane. I have divided into two splitpanes,while i am click the left side pane text or button... side pane using "JPanel". Please send the code as soon as possible. Thanks
color changing - Java Beginners
){ JFrame frame = new JFrame("Tabbed Pane Frame..., BorderLayout.CENTER); tab.add("Tab 1", new JLabel("This is Tabbed Pane 1")); tab.add("Tab 2", new JLabel("This is Tabbed Pane 2")); tab.add("Tab 3", new JLabel
Change the color of the selected tab
created a tabbed pane and add four tabs to it. The UIManager.put("... void main(String[] args) { JFrame frame = new JFrame("Tabbed Pane Frame...(tab, BorderLayout.CENTER); tab.add("Tab 1", new JLabel("This is Tabbed Pane 1
JSP - Java Beginners
class TableApplet extends Applet{ JTable table; JScrollPane pane; public void..."} }, new String[] {"Name", "Address"}); pane=new JScrollPane(table); add(pane); setSize(300,100); } } 2)jtable.jsp
XML and swings - Java Beginners
XML and swings  I have an xml file where all the contents that should be present in the tabbed pane are there. i would like to know how to parse the xml such that, whenever it reads the component type as label, it should create
JDialog to create a customized dialog box for entering text data
dialog box for entering text data. The dialog can be split into panes, left pane can contain an image file and the right pane will contain multiple text fields
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
How to retrive an inmage from database and displaying it in imgae box - Swing AWT
or pane in a JFrame.. is this possible? can you plz help tell me how we can do...().createImage(bytes); f.getContentPane().add(new Pane(image)); f.setSize(300,100); f.setVisible(true); } } catch( Exception e ){} } } class Pane extends
scrolling problem - Framework
scrolling problem  I have eco framework application in that i created one grid on contentpane and add image on grid . i also add window pane on contentpane also. while scrolling only image is moving but window is not moving
java swings - Java Beginners
java swings   Hi, I need the code for joptionpane with jcombobox. my requirement is click on add button,one joptionpane will come.from the option pane i need to select the combobox values. Please send the sample code
question
scroll pane using java swing .If i am clicking a search button then i want... that selected file in to scroll pane on client window using client server socket
Display Image on JDesktopPane
); f.getContentPane().add(new Pane(image)); f.setSize(300, 100); f.setVisible(true); } } catch (Exception e) { } } } class Pane extends JDesktopPane { private Image image; public Pane(Image image) { this.image = image
java swing - Java Beginners
{ JPanel panel; JTextField text; JTextArea area; JScrollPane pane; JLabel l1,l2..."); area=new JTextArea(5,5); pane=new JScrollPane(area); text.addKeyListener(new...); panel.add(l2); panel.add(pane); add(panel); setSize(300,100); setVisible(true
jdbc - JDBC
= f.getToolkit().createImage(bytes); f.getContentPane().add(new Pane(image...) { } } } class Pane extends JDesktopPane { private Image image; public Pane(Image image) { this.image = image; } public void paintComponent
java - Java Beginners
pane; public OperatingSystem(){ label1=new JLabel("Opearting System Name...(scroll2); panel.add(label3); panel.add(scroll3); pane=new JTabbedPane(); pane.addTab("Information",panel); add(pane); } public static void main
Using Flex Containers
three child containers with title Pane 1, Pane 2 and Pane 3
How to get filename in JTextArea in following case?
pane; FileName(){ setLayout(null); JTextAreaOutputDirectory=new JTextArea(5,20); pane=new JScrollPane(JTextAreaOutputDirectory); b=new...(10,100,80,20); add(pane); add(b); setVisible(true); setSize(300,180
java - Java Beginners
area1,area2,area3; JScrollPane scroll1,scroll2,scroll3; JPanel panel; JTabbedPane pane...); panel.add(scroll3); pane=new JTabbedPane(); pane.addTab("Information",panel); add(pane); } public static void main(String args[]){ OperatingSystem tb=new
Java Swings problem - Swing AWT
pane. For example, if the split pane is of dimension (0,0,100, 400), then divider
JTable - Swing AWT
pane = new JScrollPane(table); getContentPane().add(pane, BorderLayout.CENTER
Tree and a desktoppane - Swing AWT
frame on the desktop pane. I do not know how to fire the event in the tree program to place the internal frame in the desktop pane as the tree class is outside

Ads