[Tex/LaTex] Stretching an \fbox horizontally to fit the page

boxescalculationsmarginsspacingwidth

I have a frame box next to some text (Komentar:), and I would like to stretch it so it fills up the page. I've done this using the calc package by subtracting \widthof{Komentar: } from \hsize (or \textwidth or \linewidth).

Komentar: \fbox{
    \newlength\mylength
    \setlength\mylength{\hsize - \widthof{Komentar: }}
    \begin{minipage}[t]{\mylength}
        \hfill
        \vspace{8cm}
    \end{minipage}
}

However, this stretches the box beyond what seems to be the right margin: I have two pieces of text with \hfill in between, and the box seems to go beyond that. In fact, it looks like the values returned by \hsize, \textwidth and \linewidth are wider than what \hfill makes it out to be. Here's a picture of what I mean:

enter image description here

So, either I'm not getting the page width correctly, or I'm doing the \hfill thing wrong. Either way, help is appreciated.

P.S. I also get a warning that the \hbox in paragraph at lines 84–92 is 17.89452pt too wide.


EDIT:
Here's an MWE. You get the custom document class I'm using here.

\documentclass[a4paper, 12pt, master]{etf}
\usepackage{calc}
\begin{document}

{\setlength\parindent{0pt}
Komentar: \fbox{
    \newlength\mylength
    \setlength\mylength{\hsize - \widthof{Komentar: }}
    \begin{minipage}[t]{\mylength}
        \hfill
        \vspace{8cm}
    \end{minipage}
}

Datum odbrane: \underline{\hspace{7em}} \hfill
Ocena: \underline{\hspace{6em}} (\underline{\hspace{2em}})
}

\end{document}

Best Answer

{\setlength\parindent{0pt}
Komentar: \fbox{ %< there is a space here
 %< Doesn't introduce a space but never allocate a register inside a group
    \newlength\mylength 
    \setlength\mylength{\hsize - \widthof{Komentar: }} %< there is a space here
    \begin{minipage}[t]{\mylength}
        \hfill
        \vspace{8cm}
    \end{minipage} %< there is a space here
}

so on the line you have Komentar: and an fbox with content that is

\hsize - \widthof{Komentar: } + 2 word spaces

wide so the width of that box taking into account the rules and padding is

\hsize - \widthof{Komentar: } + 2 word spaces + 2\fboxsep + 2\fboxrule

Probably you want to comment out the ends of lines with % to avoid adding spurious space, and to account for 2\fboxsep + 2\fboxrule in the width of the box.