Make table column invisible


Hi ,

The following code make the column invisible, but
also removes it from the model.

table.getColumnModel().removeColumn(table.getColumnModel().getColumn(0));

How can I make the column invisible, but *not* remove it from the model,
because I need to obtain the data from the invisible column later on.

Also, this is not working, since when I increase column width by dragging I can see some dots and the coumn becomes partially visible:
TableColumn idClmn= table.getColumn("Property id");
idClmn.setMaxWidth(0);
idClmn.setMinWidth(0);
idClmn.setPreferredWidth(0);

Posted On: Thursday 18th of October 2012 10:34:14 PM Total Views:  97
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




How to make Container invisble

I am working on a Swings application in which i've created a static Container which is used to enter some form fields. When i submit on this form the control is sent back to login frame which is aseparate container. But the form Container doesn't go invisble. i've used the following code to make it invisble : MainFrame.container.setvisible(false);
VIEWS ON THIS POST

108

Posted on:

Saturday 29th September 2012
View Replies!

How to make the window (JPanel?) bigger in gridbaglayout

When I run this program, the window pops up and everything is smooshed (for lack of a better term) together. How do I change the size of it I'm using GridBagLayout.
VIEWS ON THIS POST

209

Posted on:

Saturday 29th September 2012
View Replies!

Use custom font and also make that font available for other applications

I would like to use custom font (TTF), which I can do using Font.createFont(), but I would like other applications to be able to use that font which means I would like to install in my OS(my OS- windows 7) fonts directory. I tried to register to GraphicsEnvironment but other applications are not able to use that font.
VIEWS ON THIS POST

90

Posted on:

Monday 1st October 2012
View Replies!

Problem using RTFEditorKit to make a WordProcessor Like WordPad in Windows

I am using a JTextPane to make a RTF Editor or just like WordPad in Windows but when I use the RTFEditorKit it does keeps the format of another rtf files text when copied to my JtextPane like textColor,textStyle(Bold Italics)etc. but when I try to add my style to it the text gets disappeared. I think I am wrong Some where please help my code is as below : package rtf; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.InputStream; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextArea; import javax.swing.JTextPane; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultStyledDocument; import javax.swing.text.Document; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; import javax.swing.text.StyledEditorKit; import javax.swing.text.rtf.RTFEditorKit; public class ColorTextComponent extends JFrame{ Toolkit toolkit=Toolkit.getDefaultToolkit(); private static final long serialVersionUID = 1L; JTextPane jTextPane=new JTextPane(); StyledDocument styleDoc=jTextPane.getStyledDocument(); DefaultStyledDocument sdoc=new DefaultStyledDocument(); JTextArea jTextArea=new JTextArea(); Document doc=jTextArea.getDocument(); Style style; JButton red=new JButton("Red"); JButton green=new JButton("Green"); String getTString; RTFEditorKit rtfEditor=new RTFEditorKit(); //Problem Occurs here StyledEditorKit sek=new StyledEditorKit(); InputStream in; public ColorTextComponent() { setLayout(new BorderLayout()); add(jTextPane,BorderLayout.CENTER); // jTextPane.setDocument(sdoc); sek.createDefaultDocument(); sek.install(jTextPane); jTextPane.setEditorKit(rtfEditor); // rtfEditor. add(jTextArea,BorderLayout.LINE_END); add(red,BorderLayout.PAGE_START); // toolkit. green.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Style styleGreen=styleDoc.addStyle("Green", null); StyleConstants.setForeground(styleGreen, Color.GREEN); try { getTString=jTextPane.getSelectedText(); jTextPane.replaceSelection(""); styleDoc.insertString(jTextPane.getCaretPosition(), getTString ,styleGreen); jTextPane.grabFocus(); } catch (BadLocationException e1) {} } }); red.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { style=jTextPane.addStyle("Red", null); StyleConstants.setForeground(style, Color.RED); try { getTString=jTextPane.getSelectedText(); jTextPane.replaceSelection(""); styleDoc.insertString(jTextPane.getCaretPosition(), getTString ,style); System.out.println(getTString); } catch (BadLocationException e1) {} } }); add(green,BorderLayout.PAGE_END); add(red,BorderLayout.PAGE_START); } public static void main(String[] args) { ColorTextComponent ctc=new ColorTextComponent(); ctc.setVisible(true); ctc.setSize(500,500); ctc.setDefaultCloseOperation(EXIT_ON_CLOSE); } }
VIEWS ON THIS POST

128

Posted on:

Wednesday 3rd October 2012
View Replies!

How do you make the textfield and button the same size? FlowLayout

Guys, I'm using Flow Layout for my search panel for some reason.. The Jtextfield and button is of different height, I have try setting the size and etc. but it doesn't work.
VIEWS ON THIS POST

141

Posted on:

Wednesday 17th October 2012
View Replies!

How to make a button stay look like pressed?

I was wondering how I could make a button look like pressed after clicking on it until another button is clicked I can kind of simulate the clicked look by setting a lowered BevelBorder to the button but when I do that, it doesnt look exactly how it should (I want the button to look like when the mouse is pressed on it). I tried using the doClick() method but I don't think it's suitable as apart from changing the look it also fires an action. I also tried setting a default ButtonModel and calling setPressed() method on the button's model. I read somewhere that i could try using the JToggleButton class but I'm not sure how I could go about it...
VIEWS ON THIS POST

121

Posted on:

Wednesday 17th October 2012
View Replies!

To make database input using Swing

! I'm trying to do the recording in the database using Swing. I want to ask user to answer on some math question by setting the value on slider. Then, when he clicks Submit button (I named it "potvrdi") the value from JSlider should be written in database. I wrote this in the init method: try { Class.forName("com.mysql.jdbc.Driver"); String url1 = "jdbc:mysql://localhost:3306/MyNewDatabase"; con = DriverManager.getConnection(url1, "root", ""); Statement stmt1 = con.createStatement(); ResultSet rezultat1 = stmt1.executeQuery("select * from evid"); } catch(Exception e) { e.printStackTrace(); }
VIEWS ON THIS POST

164

Posted on:

Wednesday 17th October 2012
View Replies!

How to make all my graphics selectable and doubleclick with event?

Do i have to turn the images into buttons with images But i don't think i want that. If it's selected, I would like to but a border around the image to show it is selected. Then if it's double-click, i want to put some action code on the selected item. Does anyone know of a good link example of what I am trying to do
VIEWS ON THIS POST

105

Posted on:

Wednesday 17th October 2012
View Replies!

Can I make a toolbar that can be added as an Add on for Internet Explorer?

Is it possible to make a tool bar using Swing and use it as an Add on for Internet explorer browser ie I want to make a custom toolbar for Internet explorer browser using Swing If possible how can it be added to the browser Thank you Ajith
VIEWS ON THIS POST

88

Posted on:

Wednesday 17th October 2012
View Replies!

How to make JTable resize when app window is resized?

At the lower part of an swing app I have placed a JTable. I need help in making the table size along with the window when a user maxamized or resized the window. I have tried Here is the code private JScrollPane getJScrollPane0() { if (jScrollPane0 == null) { jScrollPane0 = new JScrollPane(); jScrollPane0.setPreferredSize(new Dimension(2000, 1500)); jScrollPane0.setMaximumSize(new Dimension(2000, 1500)); jScrollPane0.setViewportView(getJTable0()); } return jScrollPane0; } private JTable getJTable0() { if (gcDiskUsageTable == null) { gcDiskUsageTable = new JTable(); gcDiskUsageTable.setAutoCreateRowSorter(true); gcDiskUsageTable.setFillsViewportHeight(true); // gcDiskUsageTable.setAutoResizeMode(HEIGHT); gcDiskUsageTable.setModel(new DefaultTableModel(new Object[][] { { null, null, null, }, }, new String[] { "Size", "dir", "File", }) { private static final long serialVersionUID = 1L; Class[] types = new Class[] { Long.class, String.class, String.class }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } }); } return gcDiskUsageTable; } private void initComponents() { setLayout(new GroupLayout()); add(getJLabel1(), new Constraints(new Leading(10, 83, 10, 10), new Leading(20, 10, 10))); add(getSearchButton(), new Constraints(new Leading(10, 10, 10), new Leading(115, 45, 440))); add(getJScrollPane0(), new Constraints(new Bilateral(10, 10, 24), new Leading(155, 319, 11, 11))); add(getJLabel2(), new Constraints(new Leading(105, 783, 10, 10), new Leading(119, 45, 440))); add(getJButton0(), new Constraints(new Leading(105, 10, 10), new Leading(16, 11, 11))); add(getStartFolderLabel(), new Constraints(new Leading(188, 10, 10), new Leading(20, 11, 11))); setJMenuBar(getJMenuBar0()); setSize(900, 500); }
VIEWS ON THIS POST

77

Posted on:

Wednesday 17th October 2012
View Replies!

How to make label visible

I have created a radio button group with two buttons in NetBeans, and I would like some text to show up when the button is chosen and become greyed out when it is not chosen. I have tried adding the code: private void rdoNoFracActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: lblIWillChoose.setVisible(true); lblIWillChoose.setEnabled(true); lblUserFrac.setEnabled(false); lblUserFrac.setVisible(false); }
VIEWS ON THIS POST

156

Posted on:

Wednesday 17th October 2012
View Replies!

How To make a Window non-focusable in SWT

How To make a Window non-focusable in SWT
VIEWS ON THIS POST

62

Posted on:

Wednesday 17th October 2012
View Replies!

You know how macs make one button pulse?

If you request focus on one button, you'll get a little blue circle around it. Macs also seem capable of making one button pulse blue, usually the OK button. As an example that is (I think) done in java, look at file -> properties in eclipse. Anyone know how to pulse like that
VIEWS ON THIS POST

57

Posted on:

Wednesday 17th October 2012
View Replies!

how to make Canvas transparent ?

all, sorry for the double posting but its different subject . i have Canvas and i like to make its background transparent , but with no luck the canvas is create on canvas parent . can it be done with canvas or i need to use other control
VIEWS ON THIS POST

66

Posted on:

Wednesday 17th October 2012
View Replies!

How to make text field to accept only alphabets.

I have a First name Text field.I want to make this text field to accept only characters. How to make this text field to restrict accepting numbers and special characters.
VIEWS ON THIS POST

63

Posted on:

Wednesday 17th October 2012
View Replies!

How to make Resize JButton() on mouse click...

Hi ... I am herewith enclosed my sample code for resize the JButton(),But This one resize the when will be extend the Button Caption letters,But i want mouse click resize the without button caption or with caption. sample code : package Resize; import java.awt.Container; import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JFrame; import java.awt.Dimension; import java.awt.ComponentOrientation; public class ReButton{ public static boolean RIGHT_TO_LEFT = false; public static void addComponents(Container contentPane) { if (RIGHT_TO_LEFT) { contentPane.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT); } contentPane.setLayout(new FlowLayout()); contentPane.add(new JButton("1")); contentPane.add(new JButton("100")); contentPane.add(new JButton("100 100")); contentPane.add(new JButton("100 100 100")); contentPane.add(new JButton("100 100 100 100")); contentPane.add(new JButton("5")); } private static void createAndShowGUI() { JFrame frame = new JFrame("FlowLayoutDemo") { public Dimension getMinimumSize() { Dimension prefSize = getPreferredSize(); return new Dimension(100, prefSize.height); } }; frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. addComponents(frame.getContentPane()); //Display the window. frame.pack(); frame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } } ************************
VIEWS ON THIS POST

126

Posted on:

Thursday 18th October 2012
View Replies!

make certain JTree nodes uneditable

hello, PART 1: i am using the classes found on this webpage http://java.sun.com/products/jfc/tsc/articles/jtree/ i want a user to be able to modify any folder on his/her system except for system dependant folders such as WINDOWS and Documents And Settings. I think Windows will not allow this anyway, but I still would like these and maybe other nodes to not be editable. I used tree.setEditable(true);
VIEWS ON THIS POST

70

Posted on:

Thursday 18th October 2012
View Replies!

How to make popup invisible

If I run the following application and then right-click on the application, a popup menu will show up. If I move mouse outside the frame (I try to make JComponent visible so that I can move mouse outside JComponent, but I cannot make it happen), popup menu is still visible. I try to add the following to mouseExited method: popupMenu.setVisible(false); or add the following to let popup listen to mouse listener: popupMenu.addMouseListener(new MouseListener(){ public void mouseExited(final MouseEvent e) { System.out.println("Mouse Exited..."); popupMenu.setVisible(false); //line added } public void mouseEntered(final MouseEvent e) { System.out.println("Mouse Entered..."); } public void mousePressed(final MouseEvent e) { System.out.println("Mouse pressed..."); } public void mouseReleased(final MouseEvent e) { } public void mouseClicked(final MouseEvent e) { System.out.println("Mouse Clicked..."); } });
VIEWS ON THIS POST

109

Posted on:

Thursday 18th October 2012
View Replies!

How to make an 'expandable' button-like component

Sort of like in Visio with its stencils, I want to have left column components that expand when pressed. So when not pressed, it looks like a standard row in a table of contents or something. But when pressed, the sub-elements are displayed. I guess what I want is similar to an expandable tree node, but without the look and feel of a tree node. Any advice
VIEWS ON THIS POST

69

Posted on:

Thursday 18th October 2012
View Replies!

How do I make two frame visible simaltenously

Hi! I am having two frame frm1 and frm2. fr1 contains one button and textarea. frm2 contains combo box that contains some text. When I clicks on button frm2 gets visible but frm1 gets mininized, I want to make both the frame visible simaltaneously so that I can insert some text in textarea of frm1 by selectin text from combo box of frm2. Just like modeless dialog box. Is it possible, if yes then how
VIEWS ON THIS POST

88

Posted on:

Thursday 18th October 2012
View Replies!