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); }
Posted On: Wednesday 17th of October 2012 09:40:14 PM Total Views:  115
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




how to make my jtextfield smaller ?

i have put a jtextfield at the menubar by using createHorizontalGlue() to make the jtextfield at the right most part of my menubar it appears at the right most part of my menubar but the width of that jtextfield doesn't changes i try to make it shorter but that is not working can you have any other method to solve my problem all i need is my jtextfield should have 30 columns but now it have more than 100 columns and strange thing is i m unable to change this size by invoking any methods.
VIEWS ON THIS POST

204

Posted on:

Monday 24th September 2012
View Replies!

how to make rich desktop applications?

hii, i want to know how to make rich desktop application can i make them using swing only\t else where i have to look to make rich desktop apps Thank you
VIEWS ON THIS POST

59

Posted on:

Tuesday 25th September 2012
View Replies!

How to make rotated text "look good"

My question is not about how to rotate text with Java2D; I know how to do that. What I don't know is how to make the rotated text "look good." For example, if you create a text box in PowerPoint and rotate it, the text appears sharp and clear no matter the rotation angle. However, text drawn with g2D.drawString() looks okay at 0 or 90 degrees but not so good at other angles. This is especially so for smaller fonts. Is there a way to manipulate the text to clean or sharpen it up I've tried using: g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
VIEWS ON THIS POST

93

Posted on:

Tuesday 25th September 2012
View Replies!

How to make card game like rummy card game.

I am working on some project , like rummy card game , I want to use java applet for developing this game, and also graphics, panels, label will be used for this. So please tell me what will be the best way that I can developed my application, please give me the way.........please help me I am confused. I have make one java applet for this card game, but its not working properly that I want, now I want to make applet from scratch, and I am using 104 cards images for play this game, maximum six player will be play this game, card image will be drag and drop and many more so please help me to find out right way.
VIEWS ON THIS POST

98

Posted on:

Tuesday 25th September 2012
View Replies!

how to make a sub tabbedpane in each pane?

import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JButton; import javax.swing.*; import java.awt.event.*; public class tabbedpane1 extends JFrame { public tabbedpane1() { //This will create the title you see in the upper left of the window setTitle("Tabbed Pane"); setSize(300,300); //set size so the user can "see" it //Here we are creating the object JTabbedPane jtp = new JTabbedPane(); //This creates the template on the windowed application that we will be using getContentPane().add(jtp); JPanel jp1 = new JPanel();//This will create the first tab JPanel jp2 = new JPanel();//This will create the second tab //This creates a non-editable label, sets what the label will read //and adds the label to the first tab JLabel label1 = new JLabel(); label1.setText("content 1"); //This adds the first and second tab to our tabbed pane object and names it jtp.addTab("Tab1", jp1); jtp.addTab("Tab2", jp2); //This creates a new button called "Press" and adds it to the second tab JButton test = new JButton("Press"); jp2.add(test); //This is an Action Listener which reacts to clicking on //the test button called "Press" ButtonHandler phandler = new ButtonHandler(); test.addActionListener(phandler); setVisible(true); //otherwise you won't "see" it } //This is the internal class that defines what the above Action Listener //will do when the test button is pressed. class ButtonHandler implements ActionListener{ public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog(null, "I've been pressed", "What happened", JOptionPane. INFORMATION_MESSAGE); } } //example usage public static void main (String []args){ TabbedPane tab = new TabbedPane(); } }
VIEWS ON THIS POST

50

Posted on:

Wednesday 26th September 2012
View Replies!

how to make zooming slowly

everybody. Does anybody have any ideas how to make animated zoom. What I mean by this is how to make zooming slowly showing how it is zooming not at once. Any ideas
VIEWS ON THIS POST

88

Posted on:

Wednesday 26th September 2012
View Replies!

BufferedImage makes black quadrate instead of picture

can anyone help to spot my mistake I have a code and exactly in this code somewhere is mistake because it saves black image here is code: class saving implements ActionListener{ public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub title = JOptionPane.showInputDialog(null, "choose the name of the file", "file name", JOptionPane.QUESTION_MESSAGE); try{ BufferedImage bi = new BufferedImage(700, 700, BufferedImage.TYPE_INT_RGB); File outputfile = new File(title+".jpg"); ImageIO.write(bi, "jpg", outputfile); } catch (IOException i) { } } }
VIEWS ON THIS POST

98

Posted on:

Wednesday 26th September 2012
View Replies!

Trying to make a button but don't know where to start

I'm trying to make a button that will change the color of the block when clicked. Just need to know how to set the actionListener for the colors here is the code that I'm working with: import java.applet.Applet; import java.awt.*; public class Grid extends Applet{ int boxSize=70; int gridSize=4; Box b1; Box b2; Box b3; Box b4; Box b5; Box b6; Box b7; Box b8; Box b9; Box b10; Box b11; Box b12; Box b13; Box b14; Box b15; Box b16; public void init(){ b1 = new Box(0 * boxSize , 0*boxSize, boxSize, boxSize, new Color(0* 255/ gridSize, 0* 255/ gridSize , 0)); b2 = new Box(1 * boxSize , 0*boxSize, boxSize, boxSize, new Color(1* 255/ gridSize , 0* 255/ gridSize , 0)); b3 = new Box(2 * boxSize , 0*boxSize, boxSize, boxSize, new Color(2* 255/ gridSize , 0* 255/ gridSize , 0)); b4 = new Box(3 * boxSize , 0*boxSize, boxSize, boxSize, new Color(3* 255/ gridSize , 0* 255/ gridSize , 0)); b5 = new Box(0 * boxSize , 1*boxSize, boxSize, boxSize, new Color(0* 255/ gridSize , 1* 255/ gridSize , 0)); b6 = new Box(1 * boxSize , 1*boxSize, boxSize, boxSize, new Color(1* 255/ gridSize , 1* 255/ gridSize , 0)); b7 = new Box(2 * boxSize , 1*boxSize, boxSize, boxSize, new Color(2* 255/ gridSize , 1* 255/ gridSize , 0)); b8 = new Box(3 * boxSize , 1*boxSize, boxSize, boxSize, new Color(3* 255/ gridSize , 1* 255/ gridSize , 0)); b9 = new Box(0 * boxSize , 2*boxSize, boxSize, boxSize, new Color(0* 255/ gridSize, 2* 255/ gridSize , 0)); b10 = new Box(1 * boxSize , 2*boxSize, boxSize, boxSize, new Color(1* 255/ gridSize, 2* 255/ gridSize , 0)); b11 = new Box(2 * boxSize , 2*boxSize, boxSize, boxSize, new Color(2* 255/ gridSize, 2* 255/ gridSize , 0)); b12 = new Box(3 * boxSize , 2*boxSize, boxSize, boxSize, new Color(3* 255/ gridSize, 2* 255/ gridSize , 0)); b13 = new Box(0 * boxSize , 3*boxSize, boxSize, boxSize, new Color(0* 255/ gridSize, 3* 255/ gridSize , 0)); b14 = new Box(1 * boxSize , 3*boxSize, boxSize, boxSize, new Color(1* 255/ gridSize, 3* 255/ gridSize , 0)); b15 = new Box(2 * boxSize , 3*boxSize, boxSize, boxSize, new Color(2* 255/ gridSize, 3* 255/ gridSize , 0)); b16 = new Box(3 * boxSize , 3*boxSize, boxSize, boxSize, new Color(3* 255/ gridSize, 3* 255/ gridSize , 0)); } public void paint(Graphics g){ b1.display(g); b2.display(g); b3.display(g); b4.display(g); b5.display(g); b6.display(g); b7.display(g); b8.display(g); b9.display(g); b10.display(g); b11.display(g); b12.display(g); b13.display(g); b14.display(g); b15.display(g); b16.display(g); } }
VIEWS ON THIS POST

88

Posted on:

Wednesday 26th September 2012
View Replies!

Easiest way to make Java GUIs like in Visual Studio?

Im going to use Visual Studio (C#) just because it is so difficult to do GUIs in MyEclipse. I mean just dragging a button and trying to resize it is near impossible. VS has always been so almost instinct. Maybe Im doing something wrong as I would perfer that my entire system be Java based for compatibility. Is there some kind of way to make it all simple and easy to create GUIs
VIEWS ON THIS POST

99

Posted on:

Thursday 27th September 2012
View Replies!

how to make Jlsit as Checkbox using model in Java Swing

i have create the new JList as below:- JList AttachFileList = new JList(model); AttachFileList.setCellRenderer(new CheckBoxListCellRenderer()); AttachFileList.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION); AttachFileList.setModel(model); class CheckBoxListCellRenderer extends JComponent implements ListCellRenderer { //private static final long serialVersionUID = 1L; DefaultListCellRenderer defaultComp; JCheckBox checkbox; public CheckBoxListCellRenderer() { setLayout(new BorderLayout()); defaultComp = new DefaultListCellRenderer(); /* defaultComp.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION);*/ checkbox = new JCheckBox(); checkbox.setBackground(getBackground()); checkbox.setSelected(false); // checkbox.setSelected(true); add(checkbox, BorderLayout.WEST); add(defaultComp, BorderLayout.CENTER); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { defaultComp.getListCellRendererComponent(list, value, index,isSelected, cellHasFocus); checkbox.setSelected(isSelected); return this; } } problem is that when i clicked one of the item in the JList i can't deselect it my clicking it once again please help me. . . i'll will help full to my project. . . .
VIEWS ON THIS POST

68

Posted on:

Friday 28th September 2012
View Replies!

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

88

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

156

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

80

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

103

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

123

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

79

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

141

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

89

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

78

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

66

Posted on:

Wednesday 17th October 2012
View Replies!