Box « Component « Java Swing Q&A





1. SWT Notification animated box (a.k.a toaster) needed    stackoverflow.com

In a Java project (SWT desktop app), I want to inform the user about events through animated notification box (actually, it's not required to be animated). Something like MSN or any ...

2. Is there a "Group Box" equivalent in Java Swing?    stackoverflow.com

Trying to build a GUI application in Java/Swing. I'm mainly used to "painting" GUIs on the Windows side with tools like VB (or to be more precise, Gupta SQLWindows... wonder how ...

3. Java GUI guidance on building a chat box    stackoverflow.com

I'm just looking for a little guidance as to how i might implement a chat box. There needs to be a text area for user entry, and a scrolling list of past ...

4. "Zoom" text to be as big as possible within constraints/box    stackoverflow.com

First problem: You have 400 pixels width to go on, and need to fit some text within that constraint as large as possible (thus, the text shall use that amount of ...

5. How to obtain bounding box of transformed text(java)?    stackoverflow.com

Currently I have a text object that I need to determine its bounds. I used to use the graphics object to obtain the font metrics of the text I am trying ...

6. Stretching in Java Swing Box    stackoverflow.com

I have a code:

    Box box_general = Box.createHorizontalBox();
    Box box_panel1 = Box.createVerticalBox();
    Box box_panel2 = Box.createVerticalBox();

    JPanel jpanel_1 = ...

7. java swing timer how to hide box and reappear after 1 hour    stackoverflow.com

Edited for more clearer picture I am using swing timer to make JFrame to come out at certain time, so user have an option to click Hide button, once user click hide, ...

8. How to make font bold in java dialogue box?    stackoverflow.com

I have this:

JOptionPane.showMessageDialog(null, " " + company1 + 
            " Has Higher A Market Value\nThan " + company2,
   ...

9. Dynamic text box in Java    stackoverflow.com

how do I make a text box which the user can insert text into, then that text can be saved to some variable?





10. Swing component and jdk version issue    stackoverflow.com

I have a combo box. After selecting an item in combo box new JDialog opens.

  1. When i use JDK 1.6_06, I am able to click on buttons in JDialog properly.
  2. When i use JDK ...

11. Drawing a selection box using Swing    stackoverflow.com

I have written an application with a panel and three buttons. I want to add selection this buttons using the mouse. I mean like we have in Windows on the Desktop. ...

12. Create a plain message box that disappears after a few seconds in Java    stackoverflow.com

I wonder what is the best approach to make a JOptionPane style plain message box disappear after being displayed for a set amount of seconds. I am thinking to fire up a ...

13. drawing boxes in java    stackoverflow.com

I have wrote a program that simulates memory allocation with first fit and best fit algorithms . Now I want to associate my program with a drawing of set of boxes representing ...

14. Refreshing the Contents of a Box after changing the contents    stackoverflow.com

I have a java Box in which are various components. When the user performs an action, I want to empty the box, put a different set of components in ...

15. java Box.glue not working as expected    stackoverflow.com

I am writing a class where I want to be able to add an unknown number of panels to another JPanel in a vertical BoxLayout. theses panels each consist of a ...

16. Popup Message boxes    stackoverflow.com

I am unsure of how to code popup message box in my methods.

public String verify(){
String result = "failed";
int authcode = staffBean.getVerifyCodeByName(getLoginUserName());

if ( code==authcode){       
  ...





17. Resultset to display in text box by splitting    stackoverflow.com

         public class Time extends javax.swing.JFrame {

/** Creates new form Time */
public Time() {
    initComponents();
    generate();
}

public void ...

18. iText/Swing: Breaking text in a box    stackoverflow.com

I am using iText to generate some PDF documents. It is quite easy to draw a colored rectangle. But I would like to add some text fitting into that ...

19. Java 1.6 Graphics2D: Rendering text into a box    stackoverflow.com

I am looking for an easy way to render a String into a rectangular box within a JPG whereas line breaks should happen automatically for that text box. Is this possible with ...

20. Java Swing App works as expected when run directly, but white box when run in linux netbeans debugger    forums.netbeans.org

Posted: Mon Oct 11, 2010 8:48 am Post subject: Java Swing App works as expected when run directly, but white box when run in linux netbeans debugger Hello Netbeans people! Sorry if this is an already-answered question, I was struggling to come up with the right keywords about this question, which rendered my google/forum searches rather fruitless. I ...

22. Java Guru's pl give me alternate to JDailog Box ????    coderanch.com

I am looking for alternate to dailog box,Because dialog box does not have features like regular window Minimise and maximise and closing of window. I am running this application showing some frame in window,after hit the new button it opens dailog box,i want to open more and more child frames using this new button and can minimise those child frames in ...

23. Integer box    coderanch.com

24. Messasge Box Functionality    coderanch.com

Hi guys, How can i get the effect of a message box using Swing. This is for information, Confirmation etc., . for instance, i would like to display a message " Do you really want to quit the application?" when the user clicks on the 'Exit' button. Depending on ther user response, i either close the window or put him back ...

25. Message box    coderanch.com

Hi, I made a form and i need to have a message box that inform the user if one or more field are empty. I tried with the following: <%
if (".....one field is null.....")
{
this.showMessageDialog(null,"You need to enter a value...");
}
else
{
%> <%@ include file="Response.jsp" %> <%
}

26. Show wait box while executing database query    coderanch.com

I have ran into the same problem before, and I am not real sure if there is a fix for it. I first tried to put the query in a thread, but it still ate so much CPU time that it still didn't paint my wait window. So then I tried using a wait command of some sort or a for ...

27. JCheck Box    coderanch.com

28. Tooltip shows as empty gray box?    coderanch.com

29. Array of Swing Box    coderanch.com

30. jre 1.3 - Choice Box Problem    coderanch.com

31. alert boxes    coderanch.com

I have a problem with my homewrok I read the solution ginev by Mr Daniel Searson but I am still not clear.If you could summarize how the code is wriitten I would be cery grateful. Here it is Write a simple class called Message with a single public method that brings up a modal dialog with a user specified string message. ...

32. please wait box    coderanch.com

33. text box    coderanch.com

34. Message Box problem    coderanch.com

35. Box.createGlue() creates nothing    coderanch.com

36. creating Message box    coderanch.com

37. showOpenDialog box    coderanch.com

38. Input Box?    coderanch.com

39. help on dynamic select box    coderanch.com

hi, I am new to java and am developing an application . I need suggestions to implement the requirement below. The application will have a combo box ( CB1) with 3 choices A , B and C. Another combobox (CB2) in the same frame has to reflect the choice selected in CB1. I.e for example if A is selected in CB1 ...

40. help!! on dynamic select box - 2    coderanch.com

41. closing Simple message box    coderanch.com

hi, im am trying to put a time limit on how long a user has to press "ok" to message that has been displayed. I have added a JOptionPane to a Jdialog to hopefully achieve this along with a java swing timer. I am 99% sure there is nothing wrong with the way the timer is set up. There is something ...

42. Message Box??    coderanch.com

43. how to set Box color?    coderanch.com

44. Message box problem    coderanch.com

45. Alert box!    coderanch.com

46. Please run the program in pure Unix Box    coderanch.com

Hi, everyone! Now I design a program, the following code is the GUI section. Because I need precise size and location for every component, I have to use the setBounds method to achieve this. But I heard that using such method which depends on the absolute location may cause some of the components changing their sizes and positions when the program ...

49. intelligent text box    coderanch.com

50. About box - modal / noresizeable    coderanch.com

51. SWT newbie, background grey box    coderanch.com

Hi and help, I'm new to swt, and I'm sure I'm just missing something simple. I'm trying to change the background color of a shell with a menu bar to white, red, anything other than gray. I always end up with a small gray box in the upper left corner. Why? How do I fix this? Thanks - Laurie

52. Cannot Listen for close box!    coderanch.com

53. Drawing a rectangular box    coderanch.com

Pretty much the same as drawing in the AWT except you get double buffering. And Swing overrides the update method so we are advised not to override it. The Trail: 2D Graphics is a guide to the Graphics2D resources but these are equally available in the AWT. import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.MouseInputAdapter; public class DrawBox extends JPanel { ...

54. Box... dynamically adjust strut width    coderanch.com

Hello Ranchers, I'm using a Box (box) as my custom TreeRenderer; I'm using a Horizontal Strut with in this box to get some padding between a "label" and a "button" // Construtor() ..... this.add(label); this.add(Box.createHorizontalStrut(width)); this.add(button); ..... getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { .... return this; //i.e. the box } Can you ...

56. JWindow showing up as a white box    coderanch.com

I have the code for a nice JWindow as follows package gui; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JWindow; public class UserInput implements ActionListener { private String[] codes = {"N", "V", "A", "v", "C", "P", "!", "r", "D", "I"}; private String[] words = {"Noun", ...

58. Custom message box using Swings    coderanch.com

59. Rich Text Box in Java    coderanch.com

60. Creating System Information GUI Boxes    coderanch.com

I really would sincerely appreciate the help because I am not sure where to start. In order to tuning programs to meet the hardware requirements and provide optimal performance, it is very important to retrieve system information for every program. In this assignment, you need to print out system information including: a. Display mode Width Height Bit depth Refresh rate b. ...

61. Windows Look-in-feel on Unix box?    coderanch.com

Does anyone know if there are any problems or limitations to using the Windows LNF on a unix platform? Motif is the default LNF on my Unix box and I always heard that Windows LNF in Motif causes display problems. I am developing my application in Windows with Windows LNF, but when testing my app on a Unix box with Motif ...

62. javax.swing.Box help    coderanch.com

Hi guys, I've got an app (an excercise from Chapter 13 of Head First Java) to make a drum/percussion instruments machine and I need a little help with the GUI. The JLabels on the left are in a Box component , and I need some way to get them to match up with each row of JCheckBoxes in the center (in ...

63. A (hopefully) simple "Text box" question    coderanch.com

So. I am writing a program for a Psychology study that will track mouse movement. I have not gotten too far into the project and I have already encountered a problem. In one part of the program, a consent message is to be displayed (read from a file) and then the user selects if he/she agrees. I have everything down, including ...

64. Colorizing a Box    coderanch.com

JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JLabel label = new JLabel("Option"); label.setAlignmentX(Component.LEFT_ALIGNMENT); panel.add(label); panel.setBackground(Color.DARK_GRAY); JLabel a = new JLabel ("A"); JLabel b = new JLabel ("B"); JLabel c = new JLabel ("C"); JLabel d = new JLabel ("D"); JLabel e = new JLabel ("E"); Box box = Box.createVerticalBox(); box.setBackground(Color.DARK_GRAY); box.add(a); box.add(b); box.add(c); box.add(d); box.add(e); JScrollPane jscrlpBox = new JScrollPane(box); ...

65. Run a gui from unix box on my pc.    coderanch.com

When you have started an X-Server on your Windows box, you can from a windows command prompt connect to your Unix box with telnet or ssh - when connected via the command prompt, set DISPLAY to your windows host/IP-adr., so that your Unix box know where - and which - X-server to use.

66. retrieving value from a text box    coderanch.com

public void actionPerformed(ActionEvent e) { if (e.getSource() == b7) { String str1 = Txt1.getText(); try { Class.forName("com.mysql.jdbc.Driver"); Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/bulkmail", "root", "root"); Statement st = (Statement) con.createStatement(); StringTokenizer st1 = new StringTokenizer('"'+str1+'"' , " , " , false); while(st1.hasMoreTokens()) { int rs= st.executeUpdate("INSERT INTO contacts values('"+st1.nextToken()+"')"); } System.out.println("data Inserted Successfully"); } catch (Exception e1) { System.out.println(e1); } } } ...

67. Drawing a selection box using swing    coderanch.com

I have written an application with a panel and three buttons. I want to add selection this buttons using the mouse. I mean like we have in Windows on the Desktop. I press the left mouse button and with the movement of the mouse the area selection is growing. Is there a specific interface in this or do I have it ...

68. Numeric Up Down Box    coderanch.com

69. Java Group Boxes    coderanch.com

Is there a way to do group boxes in Java? So like if I wanted to have one form that can have multiple different things on it and basically depending on the circumstances control whether they see one box or a different one? I know you can do it in C# but the program I am working on now is in ...

70. Center text in message box    coderanch.com

71. Built-in User Popup message boxes ?    java-forums.org

I want to display a quick popup box with some hard-coded text, in a different classes, just to make sure the code is getting there. It'd be great if there was a one-liner like : UserMsg.Popup("Your text here"); Are there any built-in System.xxx or Popup.xxx utilities that i can call ? Or do i have to write my own ? All ...

72. Arial font displays boxes (mapped to Estrangelo Edessa??)    java-forums.org

I'd like to display text in Arial and I get boxes. After investigating this I realize something weird is going on: Font arial = new Font("Arial", 0, 12); arial.getFamily() = Estrangelo Edessa (!) I created a report of all available java font families and apparently Arial doesn't appear there (but Arial Black and other Arial type do). Has anyone ever seen ...

73. Fitting text in box    java-forums.org

import java.awt.*; public class test extends Frame { public test() { /* retrieve max window size */ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); GraphicsConfiguration [] gc = gs[0].getConfigurations(); Rectangle r = gc[0].getBounds(); setSize(r.width, r.height); setVisible(true); } public void paint(Graphics g) { final int windowWidth = getSize().width; final int windowHeight = getSize().height; g.setColor(Color.BLUE); g.fillRect(0, 0, windowWidth, windowHeight); g.setColor(Color.WHITE); g.fillRect(0, 100, ...

74. Box.createRigidArea    java-forums.org

75. how to edit popup size box    java-forums.org

how do you edit the size of the popup box to match the size of the textfield? made it like a autocomplete thing but when the popup coms out its size if based on the words inside. and if it doesnt match any in the DB it just shows a bigger empty box. im using netbeans 6.5 hirs the codes its ...

76. Changing the font of Message box    java-forums.org

77. java message box, how to not show multiple message box with same title or content    java-forums.org

hello, how can i prevent another message box of the same content or title from displaying again if user haven't closed the existing message box? for example, program runs, then display a message box, program end, user don't close message box. program runs again, display same message box again <-- how to prevent this if message box is still displayed? thanks. ...

78. Drawing a selection box using swing    java-forums.org

I have written an application with a panel and three buttons. I want to add selection this buttons using the mouse. I mean like we have in Windows on the Desktop. I press the left mouse button and with the movement of the mouse the area selection is growing. Is there a specific interface in this or do I have it ...

79. making a formatted text box that only takes 4 integers as input?    java-forums.org

class DocumentSizeFilter extends DocumentFilter { private final int maxCharacters; private final String pattern; public DocumentSizeFilter(final int maxChars, final String pattern) { maxCharacters = maxChars; this.pattern = pattern; } @Override public void replace(FilterBypass fb, int offs, int length, String str, AttributeSet a) throws BadLocationException { if (str.matches(pattern) && (fb.getDocument().getLength() + str.length() - length) <= maxCharacters) { super.replace(fb, offs, length, str, a); } ...

80. How do I mix different fonts in the same text box    java-forums.org

I have a JTextArea in my form which needs to be able to display a mix of normal text with symbols (as in Microsoft word "symbol" font). I can't find any information on how to do that. I have to also then be able to export the contents of the text area box to a Word document. Can someone point me ...

81. ZK equivalent of Swing Box.createHorizontalGlue()?    zkoss.org

Hi,I'd like to lay out a few buttons in a row, such that the right most button be in the right edge of the panel (as the window is resized, this button should "stick" to the right). In Swing, one possibility would be to use BoxLayout and use a "glue" component in between the left side buttons and the right most ...

82. GUI With Staggered Text Boxes    forums.oracle.com

Hi, I am relatively new to creating GUIs with Java, but I have a project to do for class. My problem is that it requires me to create staggered text boxes and I am unsure how to do this. I believe I want to do this in a panel as well, since there are other components to my GUI... This is ...