Why Glass Pane becomes visible when resizing JInternalFrame?


,
I've created a JFrame with JDesktop and one JInternalFrame on it. I've also added a glasspane (which draws a black circle only) to JFrame - it's invisible by default but when I resize JInternalFrame it shows up.. is this correct behavior Why it is visible only when I resize and diappears when I release mouse button after resize How I can make it invisible when resizing JInternalFrame (Is removing JFrame's glasspane only solution)import java.awt.Graphics; import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing.JInternalFrame; import javax.swing.JPanel; public class RunMe extends JFrame { public RunMe() { this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setBounds(10, 10, 800, 600); JDesktopPane desktop = new JDesktopPane(); JInternalFrame testJIF = new JInternalFrame("test", true, true, true, true); testJIF.setBounds(10, 10, 100, 100); desktop.add(testJIF); testJIF.setVisible(true); this.add(desktop); this.setGlassPane(new MyGlassPane()); this.setVisible(true); } private class MyGlassPane extends JPanel { public MyGlassPane() { this.setOpaque(false); } @Override protected void paintComponent(Graphics g) { g.fillOval(0, 0, 100, 100); super.paintComponent(g); } } public static void main(String[] args) { new RunMe(); } }
Posted On: Wednesday 17th of October 2012 09:58:46 PM Total Views:  97
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




Refreshing glassPane

i am working on a login dialog. When the program tries to connect to the server, i want the dialog to be grey and the buttons to be inactive. I already figured out how to create and place a glassPane. My code looks roughly like this: public void okButton_actionPerformed(ActionEvent ae) { glassPane.activate(); performLogin(); glassPane.deactivate(); }
VIEWS ON THIS POST

60

Posted on:

Tuesday 25th September 2012
View Replies!

how to turn off the word wrap in jeditorpane?

my jeditorpane automatically wrap the words ..i dont want that , all i want is a horizontal bar to appear and user can write as long as he can how to do that i have tried couple of methods like i have override the getScrollableTracksViewportWidth() but that didnt help , does any one know how i can turn off the word wrap
VIEWS ON THIS POST

56

Posted on:

Tuesday 2nd October 2012
View Replies!

scrollpane problem

i m making an editor, which has one panel , which inturn has labels which contains the line number and the editor is with frame the problem is when i reachs end of the line surely editor goes up (similar when you type at the end and scrollpane allows you to view the text at the bottom of your editor) my problem is line numbers label doesnt go in upward (though it is in scrollpane) for eg line number max goes to 35 then the screen finishes after that when i press enter editor scrolls down but this number panel doesnt scrolls down i guess this will give you a better idea...what is going wrong public class LineNumberOnEditor { /** * @param args the command line arguments */ private static JEditorPane editor; private JPanel panel; private JFrame frame; private int counter; private PrintWriter tempOut,htmlOut; private BufferedReader reader; private File tempFileLocation, htmlFileLocation; private JLabel numberLabel; private int lineNoInt = 0; private Integer lineNO = lineNoInt; private JPanel lineNumberPanel ; private JScrollPane scrollpane , lineNoScrollpane; private Font font ; public void startEditor() { frame = new JFrame("Editor"); panel = new JPanel(); editor = new JEditorPane(); editor.setPreferredSize(new Dimension(1350,850)); scrollpane = new JScrollPane(editor); numberLabel = new JLabel(lineNO.toString(),JLabel.RIGHT); settingCommonFont(); settingLineNo(); settingKeyAdapter(); numberLabel.setFont(font); editor.setFont(font); editor.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); frame.add(scrollpane,BorderLayout.CENTER); frame.add(lineNoScrollpane,BorderLayout.WEST); frame.pack(); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } public static void main(String[] args) { // TODO code application logic here new LineNumberOnEditor().startEditor(); } private void settingKeyAdapter() { class KeyListener extends KeyAdapter { @Override public void keyPressed(KeyEvent e) { if(e.getKeyCode() == KeyEvent.VK_ENTER) { incrementingLNumber(); } } private void incrementingLNumber() { lineNoInt++; lineNO = lineNoInt; JLabel numberLabel = new JLabel(lineNO.toString()); lineNumberPanel.add(numberLabel); lineNumberPanel.updateUI(); numberLabel.setFont(font); System.out.println(lineNoInt); } } editor.addKeyListener(new KeyListener()); } private void settingLineNo() { lineNumberPanel = new JPanel(); lineNumberPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); lineNumberPanel.setPreferredSize(new Dimension(60,5)); BoxLayout box = new BoxLayout(lineNumberPanel, BoxLayout.Y_AXIS); lineNumberPanel.setLayout(box); lineNumberPanel.add(numberLabel); lineNoScrollpane = new JScrollPane(lineNumberPanel,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); } private void settingCommonFont() { font = new Font("Times New Roman",Font.BOLD,18); } }
VIEWS ON THIS POST

143

Posted on:

Wednesday 3rd October 2012
View Replies!

problem in erasing panel

hey i am new in java n getting this problem i want to create a program in which i am retrieving data from database and showing in gui frame but i want when submit pressed old frame's data should be get erased but instead of that it appends in that thank you for your help package javaapplication48; import java.awt.BorderLayout; import java.io.*; import java.sql.*; import javax.swing.*; import java.awt.event.*; public class JavaApplication48 implements ActionListener { private JFrame f1,f2; ResultSet rs; private JPanel p1,p2,p3,p4,p5; private JLabel l1,l2; private JRadioButton r1,r2,r3,r4; private JButton b1; public int id,i=1; private String ques,a,b,c,d,cor; Box b2=Box.createVerticalBox(); public JavaApplication48() { f1=new JFrame("eww"); f2=new JFrame("result"); b1=new JButton("Submit"); } public void launch() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:cone"); try { Statement st=con.createStatement(); String str="SELECT * FROM quizcontest where id="+i; rs=st.executeQuery(str); while(rs.next()) { id=rs.getInt("id"); ques=rs.getString("ques"); a=rs.getString("a"); b=rs.getString("b"); c=rs.getString("c"); d=rs.getString("d"); cor=rs.getString("cor"); } con.close(); } catch(SQLException e) { System.out.println("Table creation process denied");} } catch(Exception e) { e.printStackTrace(); } p1=new JPanel(); p2=new JPanel(); p3=new JPanel(); p4=new JPanel(); p5=new JPanel(); l1=new JLabel(ques); r1=new JRadioButton(a); r2=new JRadioButton(b); r3=new JRadioButton(c); r4=new JRadioButton(d); p1.add(l1); b2.add(p1); p2.add(r1); p2.add(r2); b2.add(p2); p3.add(r3); p3.add(r4); b2.add(p3); p4.add(b1); b2.add(p4); f1.add(b2,BorderLayout.CENTER); f1.setSize(400,400); //f1.pack(); f1.setVisible(true); b1.addActionListener(this); } // @Override public void actionPerformed(ActionEvent e) { f1.dispose(); i++; launch(); } public static void main(String[] args) { JavaApplication48 ob=new JavaApplication48(); ob.launch(); } }
VIEWS ON THIS POST

136

Posted on:

Wednesday 3rd October 2012
View Replies!

how to color a particular word in a jtextpane?

i have searched in the google but all examples are quite complex so this is my code can you give a example code to color a particular text like "void" so that i can learned it in a simple way please package highlighter; import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JFrame; import javax.swing.JTextPane; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultHighlighter; /** * * @author Admin */ public class Highlighter implements KeyListener{ /** * @param args the command line arguments */ JTextPane text; void gui() { JFrame frame = new JFrame(); text = new JTextPane(); frame.add(text, BorderLayout.CENTER); String s = text.getText(); s.indexOf(s); int lenght = s.length(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { // TODO code application logic here new Highlighter().gui(); } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { throw new UnsupportedOperationException("Not supported yet."); } public void keyReleased(KeyEvent e) { throw new UnsupportedOperationException("Not supported yet."); } }
VIEWS ON THIS POST

114

Posted on:

Wednesday 17th October 2012
View Replies!

printing JTables - concatenating? what about the panels?

I am printing a JTable in this manner: StringBuffer sb = new StringBuffer(); PrintRequestAttributeSet attribs = new HashPrintRequestAttributeSet(); attribs.add(new Copies(1)); attribs.add(OrientationRequested.PORTRAIT); int xx = 1; //left and right margin int yy = 1; //top and bottom margin. Note that bottom margin cannot be less than 15 mm int ww = 845; //Width int hh = 599; //Height int units = MediaPrintableArea.MM; attribs.add(new MediaPrintableArea(xx, yy, ww, hh, units)); String title = "My Table"; sb.append(title); MessageFormat footer = new MessageFormat("Page {0}"); getPayrollHeadcountList().getTable().setPreferredSize(new Dimension(500, 500)); getPayrollHeadcountTotalList().getTable().setPreferredSize(new Dimension(500, 100)); try { getPayrollHeadcountList().getTable().print(PrintMode.FIT_WIDTH, header, footer, true, attribs, false); //getPayrollHeadcountTotalList().getTable().print(PrintMode.FIT_WIDTH, header, footer, true, attribs, false); } catch (PrinterException pe) { Debug.trace(pe); }
VIEWS ON THIS POST

529

Posted on:

Wednesday 17th October 2012
View Replies!

Scroll panel problems

I am having alot of problems getting this scroll panel to work. Specifically I have the [panel on my GUI, but I cant figure out how to get the text area to populate it. Can someone please tell me what I a,m doing wrong here. These are the code portions that pertain to the scroll panel only. private JTextArea jtextarea1;//define textarea private JScrollPane scrollpane1;
VIEWS ON THIS POST

184

Posted on:

Wednesday 17th October 2012
View Replies!

linking two jpanels

i am working a desktop application,in which i am having a jpanel which is a login page,what i want is to move to other jpanel on successful login .
VIEWS ON THIS POST

133

Posted on:

Wednesday 17th October 2012
View Replies!

jtextpane.setText() removes \n

whenever i place in properly formatted html code with \n in them, they get removed when jtextpane.setText() gets called. the document.putproperty() end of line string does not work either anyone encountered this problem would like to hear your thoughts
VIEWS ON THIS POST

90

Posted on:

Wednesday 17th October 2012
View Replies!

how to add scrollpane for a jpanel with null layout manager.

I include a JPanel with a null layout in a JScrollPane, and it doesn't display the scrollbars. Why but its working with layout manager public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); for(int i = 0; i < 20; i++) { panel.add(new JButton("Button " + i)); } //Creating JScrollPane with JPanel JScrollPane scrollPane = new JScrollPane(panel); JPanel otherPanel = new JPanel(); otherPanel.setLayout(new BorderLayout()); //Adding scrollPane to panel otherPanel.add(scrollPane); frame.add(otherPanel); frame.setSize(200,200); frame.setVisible(true); }
VIEWS ON THIS POST

171

Posted on:

Wednesday 17th October 2012
View Replies!

How to insert .gif image inside a panel

I want to insert a .gif image in a panel. I am using following code : java.net.URL imageURL = getClass().getClassLoader().getResource("images/loading.gif"); ImagePanel loading = new ImagePanel(new ImageIcon(imageURL).getImage()); this.jPanel1.add(loading); Using this if I insert normal image it displays but if I changes it to loading.gif it doesn't ... What is the issue and how to fix it
VIEWS ON THIS POST

74

Posted on:

Wednesday 17th October 2012
View Replies!

How to add gutter space after each column in JTextpane?

hi, I am using a multi column JTextpane. The main problem is that there is no space among all columns. The user is unable to read the data properly by differenciating among columns. The user wants there should be gutter space after each column. So that, the matter in each column can be read in better way. I am using the following code to divide the JTextPane into columns: // Class multicolumnParagraph View public class MultiColumnParagraphView extends ParagraphView { protected int verticalStartOffset=0; protected int columnCount=1; protected int columnNumber=0; protected int restHeight=0; int[] majorOffsets=null; int[] majorSpans=null; int[] minorOffsets=null; int[] minorSpans=null; protected int columnWidth=100; protected int columnHeight=100; Point[] starts; public MultiColumnParagraphView(Element elem) { super(elem); } protected void layout(int width, int height) { super.layout(columnWidth,0); } protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans) { super.layoutMajorAxis(targetSpan,axis,offsets,spans); majorOffsets=offsets; majorSpans=spans; performMultiColumnLayout(); offsets=majorOffsets; } protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) { super.layoutMinorAxis(targetSpan,axis,offsets,spans); minorOffsets=offsets; minorSpans=spans; performMultiColumnLayout(); offsets=minorOffsets; } protected void performMultiColumnLayout() { if (majorOffsets==null || minorOffsets==null || minorOffsets.length!=majorOffsets.length) { return; } int childCount=majorOffsets.length; int vo=verticalStartOffset; int cc=1; starts=new Point[childCount]; for (int i=0; icolumnHeight) { cc++; vo=0; } starts[i].y=vo; starts[i].x=(columnNumber+cc-1)*columnWidth; majorOffsets[i]=vo; vo+=majorSpans[i]; restHeight=columnHeight-vo; minorOffsets[i]=(cc-1)*columnWidth;//+(10*(cc-1)); } if (columnCount!=cc) { columnCount = cc; preferenceChanged(getView(0),true,true); } } public float getPreferredSpan(int axis) { if (axis==View.Y_AXIS) { return columnHeight; } else { return columnWidth*columnCount; } } public float getMinimumSpan(int axis) { if (axis==View.Y_AXIS) { return columnHeight; } else { return columnWidth*columnCount; } } public float getMaximumSpan(int axis) { if (axis==View.Y_AXIS) { return columnHeight; } else { return columnWidth*columnCount; } } public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) { int ind=getViewIndexAtPoint((int)x,(int)y,a.getBounds()); View v=getViewAtPoint((int)x,(int)y,a.getBounds()); Shape childoc=getChildocation(ind,a); return v.viewToModel(x,y,childoc,bias); } protected int getViewIndexAtPoint(int x, int y, Rectangle alloc) { if (starts!=null) { for (int i=starts.length-1; i>0; i--) { if ((starts[i].x0; i--) { if ((starts[i].x
VIEWS ON THIS POST

98

Posted on:

Wednesday 17th October 2012
View Replies!

Dynamic Jpanel

OK I am taking the original post out and substituting it with this simpler problem. If you look at the code, you will see in the buildMainPanel() all I am trying to do is to create a new panel in the main container. But obciously there is this scope issue how can I get rid of this problem package desktopapplication2; import java.awt.*; import java.awt.event.*; import java.awt.font.*; import java.awt.image.BufferedImage; import javax.swing.*; public class Test { public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final Container contentPane = f.getContentPane(); GridBagLayout layout = new GridBagLayout(); contentPane.setLayout(layout); final GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(10, 0, 5, 0); gbc.weightx = 1.0; gbc.fill = gbc.HORIZONTAL; gbc.gridwidth = gbc.REMAINDER; CollapsablePanel cp1 = new CollapsablePanel("Main Queue", buildMainPanel()); //gbc.insets = new Insets(10, 0, 5, 0); contentPane.add(cp1, gbc); JButton j = new JButton("IOI"); j.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CollapsablePanel cp4 = new CollapsablePanel("test4", buildPanel()); contentPane.add(cp4, gbc); contentPane.validate(); contentPane.repaint(); } }); contentPane.add(j, gbc); f.setSize(360, 500); f.setLocation(200, 100); f.setVisible(true); } // Building the Main Panel public static JPanel buildMainPanel() { GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); gbc.weightx = 1.0; gbc.weighty = 1.0; JPanel p1 = new JPanel(new GridBagLayout()); [COLOR=Red]JButton bt1 = new JButton(new ImageIcon("/Users/sha33/NetBeansProjects/DesktopApplication2/src/desktopapplication2/r1.jpg")); p1.add(bt1, gbc); bt1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CollapsablePanel cp4 = new CollapsablePanel("test4", buildPanel()); contentPane.add(cp4, gbc); contentPane.validate(); contentPane.repaint(); } });[/COLOR] JButton bt2 = new JButton(new ImageIcon("/Users/sha33/NetBeansProjects/DesktopApplication2/src/desktopapplication2/r2.jpg")); p1.add(bt2, gbc); JButton bt3 = new JButton(new ImageIcon("/Users/sha33/NetBeansProjects/DesktopApplication2/src/desktopapplication2/r3.jpg")); p1.add(bt3, gbc); return p1; } public static JPanel buildPanel() { GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(2, 1, 2, 1); gbc.weightx = 1.0; gbc.weighty = 1.0; JPanel p1 = new JPanel(new GridBagLayout()); gbc.gridwidth = gbc.RELATIVE; p1.add(new JButton("button 1"), gbc); gbc.gridwidth = gbc.REMAINDER; p1.add(new JButton("button 2"), gbc); gbc.gridwidth = gbc.RELATIVE; p1.add(new JButton("button 3"), gbc); gbc.gridwidth = gbc.REMAINDER; p1.add(new JButton("button 4"), gbc); ; return p1; } } class CollapsablePanel extends JPanel { private boolean selected; JPanel contentPanel_; HeaderPanel headerPanel_; private class HeaderPanel extends JPanel implements MouseListener { String text_; Font font; BufferedImage open, closed; final int OFFSET = 30, PAD = 5; public HeaderPanel(String text) { addMouseListener(this); text_ = text; font = new Font("sans-serif", Font.PLAIN, 12); // setRequestFocusEnabled(true); setPreferredSize(new Dimension(200, 20)); int w = getWidth(); int h = getHeight(); /*try { open = ImageIO.read(new File("images/arrow_down_mini.png")); closed = ImageIO.read(new File("images/arrow_right_mini.png")); } catch (IOException e) { e.printStackTrace(); }*/ } protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int h = getHeight(); /*if (selected) g2.drawImage(open, PAD, 0, h, h, this); else g2.drawImage(closed, PAD, 0, h, h, this); */ // Uncomment once you have your own images g2.setFont(font); FontRenderContext frc = g2.getFontRenderContext(); LineMetrics lm = font.getLineMetrics(text_, frc); float height = lm.getAscent() + lm.getDescent(); float x = OFFSET; float y = (h + height) / 2 - lm.getDescent(); g2.drawString(text_, x, y); } public void mouseClicked(MouseEvent e) { toggleSelection(); } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } } public CollapsablePanel(String text, JPanel panel) { super(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(1, 3, 0, 3); gbc.weightx = 1.0; gbc.fill = gbc.HORIZONTAL; gbc.gridwidth = gbc.REMAINDER; selected = false; headerPanel_ = new HeaderPanel(text); setBackground(new Color(200, 200, 220)); contentPanel_ = panel; add(headerPanel_, gbc); add(contentPanel_, gbc); contentPanel_.setVisible(false); JLabel padding = new JLabel(); gbc.weighty = 1.0; add(padding, gbc); } public void toggleSelection() { selected = !selected; if (contentPanel_.isShowing()) { contentPanel_.setVisible(false); } else { contentPanel_.setVisible(true); } validate(); headerPanel_.repaint(); } }
VIEWS ON THIS POST

51

Posted on:

Wednesday 17th October 2012
View Replies!

adding one Jpanel to another

I have the following code in my tool, that adds one jpanel to another. when ever i start tool jpanLinks panel is added to jpAvailable panel , but i made changes to jpanLinks and calling the same method which adds that panel to rootpanl it is showing same panel what it contain previosly. Before and after following line are excuting correctly but this line is skipping, jpAvailable.add(objLinkTree.jpanLinks); me to solve this issue. AvailableTree class{ .......... ........... method(){ JPanel jpanLinks = new JPanel(); public JTree jtre = new JTree(root); public JScrollPane jscrl = new JScrollPane(jtre); jpanLinks.add(jscrl, new GridLayout(1,1)); } ----------- ....... } panelEditor{ ...... ... JPanel jpAvailable = new JPanel(); ....... .... method1(){ ................. ................. jpAvailable.add(objLinkTree.jpanLinks); ...................... ................ } }
VIEWS ON THIS POST

80

Posted on:

Wednesday 17th October 2012
View Replies!

Defining the exact bottom of panel for graphic component

Hi all. If I have a JFrame object and it's size has been set to a frameWidth of 300 and a frameHeight of 500 and I have a ball (circle) with radius 20 then I intend to draw the circle on the frame using the following g.drawOval(x,y,radius*2,radius*2)
VIEWS ON THIS POST

91

Posted on:

Wednesday 17th October 2012
View Replies!

problem with displaying dynamic list in Jpanel

i added a dynamic list which displays the items starts with the string entered in the Jtextfield i was able to display the list properly but when the list is clicked if there is underlying focusable object like Jtextfield list is not selected. some strange error i'm getting i have attached the screenshot of what actually happened.i'm new to swings so finding difficult to fix the bugs..please help me. private void jTextField_itemTypeKeyReleased(java.awt.event.KeyEvent evt) { try { // TODO add your handling code here: ItemMaster itemMaster = new ItemMaster(); int iCount = itemMaster.getItemNamesCount(jTextField_itemType.getText()); if (iCount == 0) { if (jList1 == null) { return; } jList1.remove(); jList1.setVisible(false); jList1.setVisibleRowCount(iCount); return; } else { strItemNamesList = new String[iCount][2]; } String[] strDisplayList = new String[iCount]; System.out.println("icount :" + iCount); strItemNamesList = itemMaster.getItemNames(jTextField_itemType.getText()); System.out.println("string text :" + jTextField_itemType.getText()); for (int iLoopIndex = 0; iLoopIndex < iCount; iLoopIndex++) { strDisplayList[iLoopIndex] = strItemNamesList[iLoopIndex][1]; System.out.println(strDisplayList[iLoopIndex]); } if (jList1 != null) { remove(jList1); System.out.println("removed"); repaint(); } //this is the popuplist class defined by me jList1 = new PopUpList(strDisplayList); jList1.setOpaque(true); ilistXpos = jTextField_itemType.getX(); MDIApplication.jTextField_selected = jTextField_itemType; iListYpos = jTextField_itemType.getY() + jTextField_itemType.getHeight(); add(jList1); jList1.setBounds(ilistXpos, iListYpos, jTextField_itemType.getWidth(), iCount * 20); System.out.println("x pos:" + ilistXpos + " ypos :" + iListYpos); jList1.setVisible(true); jList1.setRequestFocusEnabled(true); validate(); } catch (SQLException ex) { Logger.getLogger(addItem.class.getName()).log(Level.SEVERE, null, ex); } } this is the popuplist class /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package UI; import java.awt.Container; import javax.swing.JList; import javax.swing.event.ListSelectionEvent; /** * * @author Administrator */ public class PopUpList extends JList { public PopUpList(String strDisplayList[]) { remove(); setListData(strDisplayList); addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { jList1ValueChanged(evt); } }); } public void jList1ValueChanged(ListSelectionEvent evt) { MDIApplication.jTextField_selected.setText((String)getSelectedValue()); Container parent=getParent(); parent.remove(this); parent.repaint(); } }
VIEWS ON THIS POST

164

Posted on:

Wednesday 17th October 2012
View Replies!

Layouts inside panel

I am working on menu-based swing application. I am using CardLayout to display components on JFrame on clicking of the menu. I have used separate jpanel for each set of components to be diplayed inside JFrame. I would also need to layout the components dynamically on each panel on some event. For example, I will be displaying the List which is dynamically generated on clicking of the button inside the same panel. I might be having multiple dynamic components on same panel. So what approach should I take to layout the components inside the panel
VIEWS ON THIS POST

46

Posted on:

Wednesday 17th October 2012
View Replies!

j option pane

I am thinking of using this joption pane that I saw on Sun's website. Is this easy to use, manipulate, etc...
VIEWS ON THIS POST

60

Posted on:

Wednesday 17th October 2012
View Replies!

Printing Jpanel

I have a picture on a JPanel and the size of Panel is 700x440 I need to print this panel with the size of 243x154 as a card size. I used paper.setSize(243,154) but still its printing with the same 700x440 size. How I print this with the 243x154 size. If i save Panel or save picture with this size the quality of picture effected. So I have to print this 700x440 Panel with 253x154 size. Please anyone help. Here is my Code: private void printCard(){ PrinterJob printjob = PrinterJob.getPrinterJob(); printjob.setJobName(" TESSCO CUSTOMER CARD "); printjob.setPrintable (new Printable() { public int print(Graphics pg, PageFormat pf, int pageNum){ Paper card = pf.getPaper(); card.setSize(153, 243); pf.setPaper(card); if (pageNum > 0){ return Printable.NO_SUCH_PAGE; } Graphics2D g2 = (Graphics2D) pg; g2.translate(pf.getImageableX(), pf.getImageableY()); g2.translate( 0f, 0f ); jLayeredPane2.paint(g2); return Printable.PAGE_EXISTS; } }); if (printjob.printDialog() == false) return; try { printjob.print(); } catch (PrinterException ex) { System.out.println("NO PAGE FOUND."+ex); } }
VIEWS ON THIS POST

36

Posted on:

Wednesday 17th October 2012
View Replies!

Cant able to set Background color for panel..

Hi to all, I have three panel.. consider panel1 ,panel 2 and panel3 The panel1's & panel2's Layout is Border Layout. The panel2 is added into panel1's Border Layout center.. The panel3 is added into panel2's Border Layout center... Now i was not able to set the background color for panel3.... But if i add the panel3 into panel2's Border Layout east, (or west or south or north) then i can able to set background color.. only if i am put into border layout center then only i was not able to set background color... whats reason please anybody give solution...i will be
VIEWS ON THIS POST

73

Posted on:

Wednesday 17th October 2012
View Replies!