prashant gour

Ranch Hand
+ Follow
since Feb 07, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by prashant gour

why wouldn't all Java classes be serializable?
17 years ago
Hi,
I am new to J2EE field and trying to develop a application(with JSP/Servlet) like wizard.
it will have button like back, next, finish.

on clicking on next i want to show new page and on clicking on back it shows previous page.

is there any body, who did work on this sort of application.

looking for response.

Prashant
17 years ago
JSP
I'll suggest you to use GridbagLayout because this lets you to fix the componets as you want on the panel.
GridBagConstraints gbc = new GridBagConstraints();
int anchor = GridBagConstraints.FIRST_LINE_START;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.anchor = a;
panel.add(component, gbc);


you can also add panel to panel like other component.

for detail visit this:-
http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html
17 years ago
I saw it and did follow all given suggestions but that doesn't work for me.
will you come up with solutions rather than redirecting the post.

i hope, Text area's API are not just enough to do this things. looking for another solution.
17 years ago
I am working with text area and having following requirement
1).only 80 char should be in each line.
2). after completion of 80 char caret should move to new line.
3). and one more point if 78th char is space and next word having 5 char so total count of char of line will be more than 80 char so this word should be in next line.

does anyone has done this before. looking for response.
17 years ago
I am validating one text field and showing one message box on putting wrong value in text field. Message box is coming up nicely but focus is remained in text filed where as i want focus should be on OK button of message box.

Any suggestions and thoughts!!!
17 years ago
I have gone through with given link and did try the given example in link but image does not get compressed, image is being created only with BI_RGB
Not with remaining option of compression type but size does not get decreased.


Did I make any mistake? Looking for your response.
17 years ago
there is no error and image is being created but image does not get compressed even i use method setCompressed(true).

is there any thoughts???
17 years ago
I am trying to compress bmp image but that is not showing any result, doing with following code. is there something missing in this

is there any other way which help to compress the bmp image



import java.awt.image.BufferedImage;
import java.awt.image.renderable.ParameterBlock;
import java.io.IOException;
import java.io.RandomAccessFile;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import com.sun.media.jai.codec.BMPEncodeParam;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageEncoder;
import com.sun.media.jai.codec.SeekableOutputStream;

public class ExportImages
{
private ImageEncoder encoder = null;
public static void main(String args[])
{
new ExportImages(args);
}

// Load the source image.
private PlanarImage loadImage(String imageName)
{
ParameterBlock pb = (new ParameterBlock()).add(imageName);
PlanarImage src1 = JAI.create("fileload", pb);
if (src1 == null)
{
System.out.println("Error in loading image " + imageName);
System.exit(1);
}
return src1;
}

/**
* Create seek output stream for scaling
*
* @param outFile
* @return
*/
private SeekableOutputStream createSeekOutputStream(String outFile)
{
SeekableOutputStream out = null;
try
{
out = new SeekableOutputStream(new RandomAccessFile(outFile, "rws"));
}
catch (IOException e)
{
System.out.println("IOException.");
System.exit(1);
}
return out;
}

/**
*
* @param args
*/
public ExportImages(String args[])
{
String inFile = "C:/Test.bmp";
String outputFile = "C:/Modified_image.bmp";
SeekableOutputStream out2 = createSeekOutputStream(outputFile);
PlanarImage src = loadImage(inFile);
BufferedImage bi = src.getAsBufferedImage();
ParameterBlock pb = new ParameterBlock();
pb.addSource(bi);
pb.add(1.0F);
pb.add(1.0F);
PlanarImage image = JAI.create("scale", pb, null).getRendering();
BMPEncodeParam bmpParam = new BMPEncodeParam();
bmpParam.setVersion(BMPEncodeParam.VERSION_3);
// Doing compress
bmpParam.setCompressed(true);
encoder = ImageCodec.createImageEncoder("BMP", out2, bmpParam);
try
{
encoder.encode(image);
out2.close();
}
catch (IOException e)
{
System.out.println("IOException at encoding..");
System.exit(1);
}
}
}



ThnX
17 years ago
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JViewport;
import javax.swing.table.JTableHeader;

public class FixedTable extends JFrame implements PropertyChangeListener
{
JScrollPane scrTabel1;
JTable tblFixedData = new JTable(200, 6);

public FixedTable()
{
Container container = getContentPane();
container.add(getFixedTable());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
pack();
}

private JPanel getFixedTable()
{

JTable tableTrade = new JTable(345,8);

scrTabel1 = new JScrollPane(tableTrade);

JTableHeader header = tblFixedData.getTableHeader();

JPanel pnl1 = new JPanel(new BorderLayout());
pnl1.add(header,"North");
pnl1.add(tblFixedData,"Center");

JPanel pnl = new JPanel(new GridLayout(1,2));
pnl.add(pnl1);
pnl.add(scrTabel1);

scrTabel1.addPropertyChangeListener(this);

pnl.setPreferredSize(new Dimension(300,300));

tblFixedData.setSelectionModel( tableTrade.getSelectionModel() );
tblFixedData.getTableHeader().setReorderingAllowed( false );
tblFixedData.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
tableTrade.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

return pnl;
}

public void propertyChange(PropertyChangeEvent pv){

JViewport viewport = scrTabel1.getViewport();
System.out.println(viewport);
tblFixedData.setPreferredScrollableViewportSize(viewport.getPreferredSize());
tblFixedData.revalidate();
tblFixedData.repaint();
}

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

try above code, hope this will give you some clue.
18 years ago
on action performed of button

// index tabbed index
TabbedPane.setSelectedIndex(int index);
18 years ago
your code is in working condition so write CellRenderer using DefaultTableCellRenderer in which you can disable your particular cell.
18 years ago
I have to delete selected node from Jtree except Root node. if i select all node of tree with root only child node should get deleted not root.

any thoughts!!
18 years ago
try hands on

Table.changeSelection(row, col, true/false, true/false);

Table.setColumnSelectionAllowed(true/false);
Table.setRowSelectionAllowed(true/false);

this is method of JTable.
18 years ago
if you have fixed row then use ListSelectionListener and play with these methods in valueChanged

Table.setColumnSelectionAllowed(true);
Table.setRowSelectionAllowed(true);


hope this will fine with you
18 years ago